- 论坛徽章:
- 1
|
下面是phalcon documentation摘录下来的
<?php
use Phalcon\Mvc\Micro,
Phalcon\Db\Adapter\Pdo\Mysql as MysqlAdapter;
$app = new Micro();
//Setup the database service
$app['db'] = function() {
return new MysqlAdapter(array(
"host" => "localhost",
"username" => "root",
"password" => "secret",
"dbname" => "test_db"
));
};
$app->get('/blog', function () use ($app) {
$news = $app['db']->query('SELECT * FROM news');
foreach ($news as $new) {
echo $new->title;
}
});
标红的三行
$app['db'] 来看app好像是数组,
$app->get来看,app是个类阿
<?php
class Test{
};
$c = new Test;
//$c['db']='aaa';
$a = array();
$a['db']='aaa';
//$a->get();
我自己写的的,注释掉的两行都会报错的阿
刚学php个多星期,把php从入门到精通部分的语法看了。 |
|