I have two tables in my database, schema below: user: id: ~ email_id: { type: varchar(100), required: true } password: { type: varchar(50), required: true } display_name: { type: varchar(100) } about_yourself: { type: longvarchar } web_url: { type: varchar(500) } last_active: { type: timestamp } created_at: ~ updated_at: ~ is_active: { type: tinyint, default: 2 }
article: id: ~ title: { type: varchar(400), required: true } url_slug: { type: varchar(200), required: true } user_id: { type: integer, foreignReference: id, foreignTable: user, required: true, onDelete: cascade } content: { type: longvarchar, required: true } created_at: ~ updated_at: ~ is_active: { type: boolean, default: 1 } =-================= Now, I want the list of the 5 authors who have wriiten most active articles. For That purpose, I wrote the code in the UserPeer Class: public static function getTopContributedAuthors($limit=5, $criteria=null) { $criteria = new Criteria(); $criteria->addAsColumn('user_id', ArticlePeer::USER_ID); $criteria->addAsColumn('number_of_articles', 'count(article.id)'); $criteria->addAsColumn('display_name', self::DISPLAY_NAME); $criteria->addAsColumn('about_yourself', self::ABOUT_YOURSELF); $criteria->addGroupByColumn('user_id'); $criteria->addDescendingOrderByColumn('number_of_articles'); $criteria->add(ArticlePeer::IS_ACTIVE, 1); $criteria->setLimit($limit); $criteria->addJoin(self::ID, ArticlePeer::USER_ID, Criteria::RIGHT_JOIN); return self::doSelect($criteria); } ========== But, this gives me error: 500 | Internal Server Error | PropelException [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RIGHT JOIN article ON (user.ID=article.USER_ID) WHERE article.IS_ACTIVE=1 GROUP ' at line 1] and if, I remove the line "$criteria->add(ArticlePeer::IS_ACTIVE, 1);", It is giving me Notice: Notice: Undefined offset: 6 in D:\xampp\htdocs\myarticles\lib\model\om \BaseUser.php on line 1227 I guess that there is some issue in join. Can anybody please help to identify the issue? --- Apul Gupta -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en