public function execute($sql, array $params = array()) { $sth = $this->_bindParams($sql, $params, $this->_getWriteLink()); Hook::listen('dbExecuteBegin', array($sql, $params)); if ($sth->execute()) { $affectedRows = $sth->rowCount(); Hook::listen('dbExecuteEnd', array($this->getSql(), $affectedRows)); return $affectedRows; } $err = $sth->errorInfo(); Hook::listen('dbException', array($this->getSql(), $err[2])); throw new \Exception('Database SQL: "' . $this->getSql() . '". ErrorInfo: ' . $err[2], 500); }
public function execute($sql, array $params = array()) { $this->_bindParams($sql, $params, $this->_getWriteLink()); Hook::listen('dbExecuteBegin', array($sql, $params)); $query = mysql_query($this->getSql(), $this->_getWriteLink()); if ($query) { $affectedRows = mysql_affected_rows($this->_getWriteLink()); Hook::listen('dbExecuteEnd', array($this->getSql(), $affectedRows)); return $affectedRows; } $err = mysql_error(); Hook::listen('dbException', array($this->getSql(), $err)); throw new \Exception('Database SQL: "' . $this->getSql() . '". ErrorInfo: ' . $err, 500); }