【发布时间】:2014-05-08 22:03:20
【问题描述】:
我的微应用程序有问题,我使用 PostgreSQL 作为数据库,但是我创建的数据库适配器没有为模型设置架构,我需要使用模型管理器手动完成,我该怎么做避免为每个模型手动设置架构?
这就是我创建适配器的方式
use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter;
...
return new DbAdapter(array(
"host" => $config->database->host,
"username" => $config->database->username,
"password" => $config->database->password,
"dbname" => $config->database->dbname,
"schema" => $config->database->schema,
));
这行不通
$person = new Person;
$person = $person->findFirst(1);
这行得通:
$person = new Person;
$app->modelsManager->setModelSchema($person, 'myschema');
$person = $person->findFirst(1);
如果我不手动设置架构,则模型对象找不到表,是的,架构变量设置正确。
另外我认为 Phalcon 总是使用公共架构而不是我设置的架构。
谢谢
【问题讨论】:
-
是否 $person = Person::findFirst();工作吗?
-
不,我每次都收到此错误消息:在为 Person 转储元数据时,数据库中不存在表“person”
标签: php postgresql phalcon