Hi,

Please ask these kind of question on the propel-users mailing list
(http://groups.google.com/group/propel-users) or symfony-users (http://
groups.google.com/group/symfony-users).

This list is for the development of the symfony framework itself
rather than general questions about using/installing symfony.

Regards,
[MA]Pascal

On May 18, 4:12 am, Apul Gupta <[email protected]> wrote:
> 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?
>
> --
> 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 developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/symfony-devs?hl=en

-- 
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 developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to