ZF-1881: Support associative array argument in Zend_Db_Adapter::_whereExpr()

Description

(Unable to select Zend_Db_Adapter_Abstract in Component list)

Modify _whereExpr in Zend_Db_Adapter_Abstract so that $where parameter for Zend_Db_Table_Abstract update and delete is the same as $where parameter for fetchRow and fetchAll

The Zend_Db_Adapter_Abstract::_whereExpr function needs to be changed to:


    /**
     * Convert an array, string, or Zend_Db_Expr object
     * into a string to put in a WHERE clause.
     *
     * @param mixed $where
     * @return string
     */
    protected function _whereExpr($where)
    {
        if (empty($where)) {
            return $where;
        }
        if (!is_array($where)) {
            $where = array($where);
        }
        foreach ($where as $cond => &$term) {
            // is $cond an int? (i.e. Not a condition)
            if (is_int($cond)) {
                // $term is the full condition
                if ($term instanceof Zend_Db_Expr) {
                    $term = $term->__toString();
                }
            } else {
                // $cond is the condition with placeholder,
                // and $term is quoted into the condition
                $term = $this->quoteInto($cond, $term);
            }
            $term = '(' . $term . ')';
        }

        $where = implode(' AND ', $where);
        return $where;
    }

Comments

Reword summary. Copy old summary text into description.

Patch to modify Zend_Db_Adaptor_Abstract such that where clauses are consistent between insert, update, delete and select

Fixed with attached patch

This change appears not have been applied to SVN; reassigning to [~bkarwin].

Would love to see this issue reimplemented. All of a sudden my deletes where deleting whole tables!

I've changed the code to:


    /**
     * Convert an array, string, or Zend_Db_Expr object
     * into a string to put in a WHERE clause.
     *
     * @param mixed $where
     * @return string
     */
    protected function _whereExpr($where)
    {
        if (empty($where)) {
            return $where;
        }
        if (!is_array($where)) {
            $where = array($where);
        }
        foreach ($where as  $key => &$term) {
            if ($term instanceof Zend_Db_Expr) {
                $term = $term->__toString();
            }elseif (is_string($key)) {
                $term = $this->quoteInto($key, $term);
            }
            $term = '(' . $term . ')';
        }
        $where = implode(' AND ', $where);
        return $where;
    }

Please categorize/fix as needed.

Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.

Ralph, please evaluate and decide if/how we should act on this.

Will evaluate within 2 weeks.