我推动了查询
$articles = ArticlesQuery::create()->find();
var_dump($articles);
exit;
查询文章表(id,users_id,article_category_id,images_id,title,body,approved,created_date,deleted)但我得到的结果非常不同。
预期结果是
object(PropelObjectCollection)[34]
object(Articles)[35]
protected 'startCopy' => boolean false
protected 'id' => int 1
protected 'users_id' => int 1
protected 'articles_category_id' => int 1
protected 'images_id' => int 1
protected 'title' => string 'Article Title Here updated' (length=26)
protected 'body' => resource(68, stream)
protected 'approved' => int 0
protected 'created_date' => null
protected 'deleted' => null
protected 'aUsers' => null
protected 'aArticlesCategory' => null
protected 'alreadyInSave' => boolean false
protected 'alreadyInValidation' => boolean false
protected 'validationFailures' =>
array
empty
protected '_new' => boolean false
protected '_deleted' => boolean false
protected 'modifiedColumns' =>
array
empty
protected 'virtualColumns' =>
array
empty
但我得到的结果是
object(PropelObjectCollection)[49]
object(Articles)[50]
protected 'startCopy' => boolean false
protected 'id' => int 1
protected 'users_id' => int 1
protected 'articles_category_id' => int 0
protected 'images_id' => int 0
protected 'title' => string 'xxx@gmail.com' (length=22)
protected 'body' => resource(71, stream)
protected 'approved' => int 0
protected 'created_date' => null
protected 'deleted' => null
protected 'aUsers' => null
protected 'aArticlesCategory' => null
protected 'alreadyInSave' => boolean false
protected 'alreadyInValidation' => boolean false
protected 'validationFailures' =>
array
empty
protected '_new' => boolean false
protected '_deleted' => boolean false
protected 'modifiedColumns' =>
array
empty
protected 'virtualColumns' =>
array
empty
同样的查询先前有效。我刚刚开始使用Propel ORM。我不知道出了什么问题。我已经尝试为php重新生成运行时配置,然后生成新的模型类。我已将Propel与CI集成在一起。我仍在尝试解决这个问题,我不知道是什么导致了不同的输出。
答案 0 :(得分:1)
今天,我犯了一个非常愚蠢的错误,花了我几个小时的痛苦。
实际上早上我编辑了一个推进运行时核心文件“runtime / lib / query / ModelCriteria.php”并替换了
$this->modelPeerName = constant($this->modelName . '::PEER');
// with
$this->modelPeerName = 'UsersPeer'
导致propel只返回users表中的数据。 @ j0k感谢持续的支持,让我调试这个问题。
我之前更换了代码,因为propel生成的代码不仅适用于UsersQuery而且无法定位常量($ this-> modelName。':: PEER');正常。
希望这不会发生在任何人身上,我会对跟踪我所做的改变保持警惕。找到实际错误后,我恢复到原始源,查询开始像以前一样工作。