#5780: SQL functions not working in conditions
------------------------+---------------------------------------------------
Reporter: agidise | Owner:
Type: Bug | Status: closed
Priority: Medium | Milestone: 1.2.x.x
Component: Model | Version: RC3
Severity: Major | Resolution: invalid
Keywords: | Php_version: n/a
Cake_version: |
------------------------+---------------------------------------------------
Comment (by rafaelbandeira3):
Replying to [ticket:5780 agidise]:
> Usage of functions in conditions (with the prefix -!) is not working any
more (bug seems to be present from changeset 7075 on dbo_source.php).
> Also, no test case exists to test this functionality.
>
>
> Sample code:
>
> {{{
> $mymodel->find('all', array(
> 'conditions'=>array('mydate' => '-!CURDATE()')
> ));
> }}}
>
>
> CURDATE() is quoted, which it shouldn't be.
>
>
> Simple fix as I see it - probably not fully correct, in dbo_source.php:
> {{{
> function value($data, $column = null) {
> (...)
> } else if (strpos($data, '-!') === 0) {
> return substr($data, 2);
> } else {
> return null;
> }
> }
> }}}
Using svn HEAD, you should use DboSource::expression() for this purpose.
{{{
$db =& $this->Post->getDataSource();
$this->Post->find('all', array(
'conditions'=>array('Post.modified' =>
$db->expression('CURDATE()'))
));
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/5780#comment:3>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" 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/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---