Zend_Db_Statement_Exception example

        $this->_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
            $sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);

        // map params         $this->_sqlParam = array();
        foreach ($this->_sqlSplit as $key => $val) {
            if ($val == '?') {
                if ($this->_adapter->supportsParameters('positional') === false) {
                    /** * @see Zend_Db_Statement_Exception */
                    throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$val'");
                }
            } else if ($val[0] == ':') {
                if ($this->_adapter->supportsParameters('named') === false) {
                    /** * @see Zend_Db_Statement_Exception */
                    throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
                }
            }
            $this->_sqlParam[] = $val;
        }

        

    protected function _prepare($sql)
    {
        try {
            $this->_stmt = $this->_adapter->getConnection()->prepare($sql);
        } catch (PDOException $e) {
            throw new Zend_Db_Statement_Exception($e->getMessage()$e->getCode()$e);
        }
    }

    /** * Bind a column of the statement result set to a PHP variable. * * @param string $column Name the column in the result set, either by * position or by name. * @param mixed $param Reference to the PHP variable containing the value. * @param mixed $type OPTIONAL * @return bool * @throws Zend_Db_Statement_Exception */
$bind[$newName] = $value;
                }
            }
        }

        try {
            return parent::query($sql$bind);
        } catch (PDOException $e) {
            /** * @see Zend_Db_Statement_Exception */
            throw new Zend_Db_Statement_Exception($e->getMessage()$e->getCode()$e);
        }
    }

    /** * Executes an SQL statement and return the number of affected rows * * @param mixed $sql The SQL statement with placeholders. * May be a string or Zend_Db_Select. * @return integer Number of rows that were modified * or deleted by the SQL statement */
    
Home | Imprint | This part of the site doesn't use cookies.