Php Zend_Db_选择where()和Zend_Db_适配器quoteInto()

Php Zend_Db_选择where()和Zend_Db_适配器quoteInto(),php,zend-framework,zend-db,zend-db-table,Php,Zend Framework,Zend Db,Zend Db Table,Zend_Db_Select的where()方法(当包含要完全转换的可选值)和Zend_Db_Adapte的quoteInto()方法在转义SQL方面基本相同吗 换句话说,这两个报价是否相同且同样安全 $select->where($this->getAdapter()->quoteInto('id = ?', 3)); $select->where(id = ?, 3); 谢谢 Zend_Db_Select::_where()正在使用Zend_Db_Abstract

Zend_Db_Select的where()方法(当包含要完全转换的可选值)和Zend_Db_Adapte的quoteInto()方法在转义SQL方面基本相同吗

换句话说,这两个报价是否相同且同样安全

$select->where($this->getAdapter()->quoteInto('id = ?', 3));

$select->where(id = ?, 3);
谢谢

Zend_Db_Select::_where()正在使用Zend_Db_Abstract::quoteInto()引用您在汇编sql字符串时在Zend_Db_Select::where()中指定为第二个参数的值

从Zend_Db_的第983行选择:

/**
 * Internal function for creating the where clause
 *
 * @param string   $condition
 * @param mixed    $value  optional
 * @param string   $type   optional
 * @param boolean  $bool  true = AND, false = OR
 * @return string  clause
 */
protected function _where($condition, $value = null, $type = null, $bool = true)
{
    if (count($this->_parts[self::UNION])) {
        require_once 'Zend/Db/Select/Exception.php';
        throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION);
    }

    if ($value !== null) {
        $condition = $this->_adapter->quoteInto($condition, $value, $type);
    }

    $cond = "";
    if ($this->_parts[self::WHERE]) {
        if ($bool === true) {
            $cond = self::SQL_AND . ' ';
        } else {
            $cond = self::SQL_OR . ' ';
        }
    }

    return $cond . "($condition)";
}
Zend_Db_Select::_where()正在使用Zend_Db_Abstract::quoteInto()引用您在汇编sql字符串时在Zend_Db_Select::where()中指定为第二个参数的值

从Zend_Db_的第983行选择:

/**
 * Internal function for creating the where clause
 *
 * @param string   $condition
 * @param mixed    $value  optional
 * @param string   $type   optional
 * @param boolean  $bool  true = AND, false = OR
 * @return string  clause
 */
protected function _where($condition, $value = null, $type = null, $bool = true)
{
    if (count($this->_parts[self::UNION])) {
        require_once 'Zend/Db/Select/Exception.php';
        throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION);
    }

    if ($value !== null) {
        $condition = $this->_adapter->quoteInto($condition, $value, $type);
    }

    $cond = "";
    if ($this->_parts[self::WHERE]) {
        if ($bool === true) {
            $cond = self::SQL_AND . ' ';
        } else {
            $cond = self::SQL_OR . ' ';
        }
    }

    return $cond . "($condition)";
}

据我所知,这在哪里已经如此指定它将是多余的。

据我所知,这在哪里已经如此指定它将是多余的。

谢谢!!我应该想看看源代码声明。谢谢!!我应该考虑查看源声明。Annnnnddd看起来我应该在下次点击Add之前加载新答案。Annnnnddd看起来我应该在下次点击Add之前加载新答案。