Reputation: 1907
I have propel query
$articles = ArticlesQuery::create()->find();
var_dump($articles);
exit;
which queries the article table (id, users_id, article_category_id, images_id, title, body, approved, created_date, deleted) but the result I get is very different.
expected result is
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
but the result I get is
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 '[email protected]' (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
The same query worked earlier. I have just started to work with Propel ORM. I don't know what is going wrong. I have already tried regenerating the runtime configuration for php and then generated new model classes. I have integrated Propel with CI. I am still trying to solve this problem and I have no idea what is causing the different output.
Upvotes: 0
Views: 701
Reputation: 1907
Today, I made a really stupid mistake and cost me hours of pain.
Actually in the morning I edited a propel runtime core file "runtime/lib/query/ModelCriteria.php" and replaced the
$this->modelPeerName = constant($this->modelName . '::PEER');
// with
$this->modelPeerName = 'UsersPeer'
which caused propel to return the data from users table only. @j0k Thanks for the continuous support that kept me with debugging this problem.
I replaced the code earlier because the code generated by propel was not working for the UsersQuery only and was not able to locate constant($this->modelName . '::PEER'); properly.
Hope this won't happen to anyone and I will have habbit of keeping track of changes I made. After finding the actual error, I reverted to the original source and the query began to work as before.
Upvotes: 1