Using sql functions in columns and predicates #2696

ghost opened this Issue Oct 7, 2012 · 6 comments

2 participants

    $select = $sql->select();
    $operator = new \Zend\Db\Sql\Predicate\Operator();
    $operator->setLeft('name')->setRight("CONCAT({$db->getPlatform()->quoteValue('string1')}, 'string2')")->setRightType($operator::TYPE_LITERAL);

        new \Zend\Db\Sql\Predicate\PredicateSet(array(
            new \Zend\Db\Sql\Predicate\Like('title', '%string%'),

Is there no way to achieve this? Or something to allow literal string and I'll take care the quoting and escaping?


Solves this with this.

Zend Framework member

So, since #2687 was merged, this works now, right?


It works with predicate right values and select->columns. But it is not consistent, It doesn't prepended the identifiers with the table name, like it does when you provide literal string in select->columns. Also I can't use the expression as a left operand in operator predicate, Haven't tried with other predicates yet.


Another issue I think, I'm not sure if it is done by design. The expression 3rd parameter is always an array, I'm lazy and I don't want to always type an array if I just have one parameter or all parameters have the same type.


@coudvanrm about the 3rd expression parameter: this is solved, see here:

About the orginal problem: is there still something that needs to be done?



@ghost ghost closed this Aug 23, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment