Skip to content
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

Phalcon and Oracle reserved words bug #11056

Closed
skaosYan opened this issue Oct 24, 2015 · 4 comments
Closed

Phalcon and Oracle reserved words bug #11056

skaosYan opened this issue Oct 24, 2015 · 4 comments

Comments

@skaosYan
Copy link

Phalcon 2.0.3 and Oracle 12c

Phalcon gives me the error below when I need to compare date column with SYSDATE. How to worlaround it?

$conditions = "bannerType = :bannerType: and startTime > sysdate";
$parameters = array('bannerType'=>$bannerType);
$banners = Banner::find(array($conditions,"bind" => $parameters));

Column 'sysdate' doesn't belong to any of the selected models (1), when preparing: SELECT [Vokuro\Models\Banner].* FROM [Vokuro\Models\Banner] WHERE bannerType = :bannerType: and startTime > sysdate and bannerStatus = :bannerStatus:
#0 [internal function]: Phalcon\Mvc\Model\Query->_getQualified(Array)
#1 [internal function]: Phalcon\Mvc\Model\Query->_getExpression(Array, true)
#2 [internal function]: Phalcon\Mvc\Model\Query->_getExpression(Array, true)
#3 [internal function]: Phalcon\Mvc\Model\Query->_getExpression(Array, true)
#4 [internal function]: Phalcon\Mvc\Model\Query->_getExpression(Array)
#5 [internal function]: Phalcon\Mvc\Model\Query->_prepareSelect()
#6 [internal function]: Phalcon\Mvc\Model\Query->parse()
#7 [internal function]: Phalcon\Mvc\Model\Query->execute(Array, NULL)
#8 /home/var/www/html/v1/app/controllers/BannerController.php(92): Phalcon\Mvc\Model::find(Array)
#9 [internal function]: Vokuro\Controllers\BannerController->getAllAction()
#10 [internal function]: Phalcon\Dispatcher->dispatch()
#11 /home/var/www/html/v1/public/index.php(44): Phalcon\Mvc\Application->handle()
#12 {main}

@valVk
Copy link

valVk commented Nov 2, 2015

One of the possible way is https://docs.phalconphp.com/en/latest/reference/phql.html#using-raw-sql

You will get the same object as after execution Banner::find(array($conditions,"bind" => $parameters));

Or you can bind current time from php

$conditions = "bannerType = :bannerType: and startTime > :sysdate:";
$parameters = array('bannerType'=>$bannerType, "sysdate" => <currentTimeStamp>);
$banners = Banner::find(array($conditions,"bind" => $parameters));

@skaosYan
Copy link
Author

skaosYan commented Nov 6, 2015

Thank you, raw SQL might really be an option.

What does this syntax mean ?
I've got an error for that

Parse error: syntax error, unexpected '<' in /home/var/www/html/v1/app/controllers/BannerController.php on line 53

@valVk
Copy link

valVk commented Nov 6, 2015

Probably you've used my example without changing <currentTimeStamp> to an actual value.

I do not know what is the format used in Oracle's sysdate, so used placeholder.

In MySQL there are 2 general formats CURENT_TIMESTAMP and 'Y-m-d H:i:s' (2015-11-05 12:47:10)

So in MySQL I'd used that syntax

$parameters = array('bannerType'=>$bannerType, "sysdate" => time()); //CURENT_TIMESTAMP

//OR

$parameters = array('bannerType'=>$bannerType, "sysdate" => date('Y-m-d H:i:s')); //current date time

@sergeyklay
Copy link
Contributor

Phalcon does not support Oracle. Refer to #12008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants