New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] \Phalcon\Mvc\Model\Query\Builder ... #1542

Closed
ovr opened this Issue Nov 10, 2013 · 1 comment

Comments

Projects
None yet
3 participants
@ovr
Contributor

ovr commented Nov 10, 2013

Hi All)

/**
 * @var $model \User\Model\Follow\User
 */
$model = $this->getModel();

$builder = $this->createQuery('fu')
    ->columns('fu.*, Follower.*')

    ->join('User\Model\User', 'fu.user_id = Follower.id', 'Follower')

    ->where('fu.author_user_id = '.$userId)
    ->andWhere('fu.user_id <> '.$userId)

    ->orderBy('fu.'.$model->getPrimaryKey().' DESC');

if ($days >= 1) {
    $builder->andWhere('DATE(fu.createdDate) >= SUBDATE(CURRENT_DATE, '.$days.')');
} else {
    $builder->andWhere('DATE(fu.createdDate) >= CURRENT_DATE');
}

Exception:

Fatal error: Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Column 'CURRENT_DATE' doesn't belong to any of the selected models (1), when preparing: SELECT fu., Follower. FROM [User\Model\Follow\User] AS [fu] JOIN [User\Model\User] AS [Follower] ON fu.user_id = Follower.id WHERE ((fu.author_user_id = 11000) AND (fu.user_id <> 11000)) AND (DATE(fu.createdDate) >= SUBDATE(CURRENT_DATE, 1)) ORDER BY fu.favoriteauthor_id DESC LIMIT 100' in /home/zaets28rus/www/uniqhand-sandbox/app/modules/user/models/Follow/UserTable.php on line 184

Phalcon\Mvc\Model\Exception: Column 'CURRENT_DATE' doesn't belong to any of the selected models (1), when preparing: SELECT fu., Follower. FROM [User\Model\Follow\User] AS [fu] JOIN [User\Model\User] AS [Follower] ON fu.user_id = Follower.id WHERE ((fu.author_user_id = 11000) AND (fu.user_id <> 11000)) AND (DATE(fu.createdDate) >= SUBDATE(CURRENT_DATE, 1)) ORDER BY fu.favoriteauthor_id DESC LIMIT 100 in /home/zaets28rus/www/uniqhand-sandbox/app/modules/user/models/Follow/UserTable.php on line 184

When i am using CURDATE() its okey

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ghost

This comment has been minimized.

ghost commented Dec 11, 2013

Please try CURRENT_DATE() instead of CURRENT_DATE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment