function query($query, $unbuffered = false) { $result = ibase_query($query, $this->_link); if (!$result) { $this->errno = ibase_errcode(); $this->error = ibase_errmsg(); return false; } $this->error = ""; if ($result === true) { $this->affected_rows = ibase_affected_rows($this->_link); return true; } return new Min_Result($result); }
public function execute($sql, array $data = null) { $this->connect(); if (!is_array($data)) { $data = array(); } $data = array_values($data); foreach ($data as $i => $v) { switch (gettype($v)) { case 'boolean': case 'integer': $data[$i] = (int) $v; break; case 'array': $data[$i] = implode(',', $v); break; case 'object': $data[$i] = serialize($data[$i]); break; case 'resource': if (is_resource($v) && get_resource_type($v) === 'stream') { $data[$i] = stream_get_contents($data[$i]); } else { $data[$i] = serialize($data[$i]); } break; } } array_unshift($data, $sql); $temp = call_user_func_array("\\ibase_execute", $data); if (!$temp) { throw new DatabaseException('Could not execute query : ' . \ibase_errmsg() . ' <' . $sql . '>'); } $this->aff = \ibase_affected_rows($this->lnk); return $temp; }
/** * Retrieve number of affected rows for last query * * @return int */ protected function affectedRows() { return ibase_affected_rows($this->handle); }
/** * Affected Rows * * @access public * @return integer */ function affected_rows() { return @ibase_affected_rows($this->result_id); }
/** * Ejecuta un query sobre la conexion existente. Si se produce algun error * se puede consultar con getError(). * @param string Sentencia sql * @return result */ public function query($query) { $this->result = null; if ($_SESSION['VARIABLES']['EnvPro']['log'] === '1') { $fp = fopen($this->logQueryFile, "a"); fwrite($fp, date("Y-m-d H:i:s") . "\t" . $query . "\n"); fclose($fp); } switch (self::$dbEngine) { case 'mysql': //mysql_select_db($this->getdataBase()); $this->result = mysql_query($query, self::$dbLinkInstance); if (!$this->result) { $this->setError("query", $query); } else { $this->affectedRows = mysql_affected_rows(self::$dbLinkInstance); } break; case 'mssql': //mssql_select_db($this->dataBase); $query = str_replace("`", "", $query); $this->result = mssql_query($query, self::$dbLinkInstance); if (!$this->result) { $this->setError("query", $query); } else { $this->affectedRows = mysql_affected_rows(self::$dbLinkInstance); } break; case 'interbase': $query = str_replace("`", "", $query); $this->result = ibase_query(self::$dbLinkInstance, $query); if (!$this->result) { $this->setError("query", $query); } else { $this->affectedRows = ibase_affected_rows(self::$dbLinkInstance); } break; case 'pgsql': $query = str_replace("`", "", $query); $this->result = pg_query(self::$dbLinkInstance, $query); if (!$this->result) { $this->setError("query", $query); } else { $this->affectedRows = pg_affected_rows(self::$dbLinkInstance); } break; default: $this->setError("query", "No se ha indicado el tipo de base de datos"); } return $this->result; }
function _performQuery($queryMain) { $this->_lastQuery = $queryMain; $this->_expandPlaceholders($queryMain, $this->DbSimple_Ibase_USE_NATIVE_PHOLDERS); $hash = $queryMain[0]; if (!isset($this->prepareCache[$hash])) { $this->prepareCache[$hash] = @ibase_prepare(is_resource($this->trans) ? $this->trans : $this->link, $queryMain[0]); } else { // Prepare cache hit! } $prepared = $this->prepareCache[$hash]; if (!$prepared) { return $this->_setDbError($queryMain[0]); } $queryMain[0] = $prepared; $result = @call_user_func_array('ibase_execute', $queryMain); // ATTENTION!!! // WE MUST save prepared ID (stored in $prepared variable) somewhere // before returning $result because of ibase destructor. Now it is done // by $this->prepareCache. When variable $prepared goes out of scope, it // is destroyed, and memory for result also freed by PHP. Totally we // got "Invalud statement handle" error message. if ($result === false) { return $this->_setDbError($queryMain[0]); } if (!is_resource($result)) { // Non-SELECT queries return number of affected rows, SELECT - resource. return @ibase_affected_rows(is_resource($this->trans) ? $this->trans : $this->link); } return $result; }
public function affected_rows() { return ibase_affected_rows($this->handler); }
/** * Gets the number of affected rows by the last INSERT, UPDATE or DELETE query. * @return int|FALSE number of rows or FALSE on error */ public function getAffectedRows() { return ibase_affected_rows($this->connection); }
/** +---------------------------------------------------------- * 执行语句 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param string $str sql指令 +---------------------------------------------------------- * @return integer +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ public function execute($str) { $this->initConnect(true); if (!$this->_linkID) { return false; } $this->queryStr = $str; //释放前次的查询结果 if ($this->queryID) { $this->free(); } N('db_write', 1); // 记录开始执行时间 G('queryStartTime'); $result = ibase_query($this->_linkID, $str); $this->debug(); if (false === $result) { $this->error(); return false; } else { $this->numRows = ibase_affected_rows($this->_linkID); $this->lastInsID = 0; return $this->numRows; } }
/** * Ejecuta un query sobre la conexion existente. Si se produce algun error * se puede consultar con getError(). * @param string Sentencia sql * @return result */ public function query($query) { $this->result = null; switch ($this->dbEngine) { case 'mysql': //mysql_select_db($this->getdataBase()); $this->result = mysql_query($query, $this->dbLink); //$fp = fopen("log/queries.sql", "a"); //fwrite($fp, date("Y-m-d H:i:s")."\t".$query."\n"); //fclose($fp); if (!$this->result) { $this->setError("query"); } else { $this->affectedRows = mysql_affected_rows($this->dbLink); } break; case 'mssql': //mssql_select_db($this->dataBase); $this->result = mssql_query($query, $this->dbLink); if (!$this->result) { $this->setError("query"); } else { $this->affectedRows = mysql_affected_rows($this->dbLink); } break; case 'interbase': $query = str_replace("`", "", $query); $this->result = ibase_query($this->dbLink, $query); if (!$this->result) { $this->setError("query"); } else { $this->affectedRows = ibase_affected_rows($this->dbLink); } break; default: $this->setError("query", "No se ha indicado el tipo de base de datos"); } return $this->result; }
public function affectedRows() { if (!empty($this->connect)) { return ibase_affected_rows($this->connect); } else { return false; } }
function _performQuery($queryMain) { $this->_lastQuery = $queryMain; $this->_expandPlaceholders($queryMain, false); $result = ibase_query($this->link, $queryMain[0]); if ($result === false) { return $this->_setDbError($queryMain[0]); } if (!is_resource($result)) { // Non-SELECT queries return number of affected rows, SELECT - resource. return @ibase_affected_rows($this->link); } return $result; }
/** * Renvoie le nombre de lignes affectées par la dernière requète DML * * @access public * @return boolean */ function affectedRows() { return ibase_affected_rows($this->link); }
/** * returns the affected rows of a query * * @return mixed MDB Error Object or number of rows * @access public */ function affectedRows() { if (function_exists('ibase_affected_rows')) { //PHP5 only $affected_rows = @ibase_affected_rows($this->connection); if ($affected_rows === false) { return $this->raiseError(MDB_ERROR_NEED_MORE_DATA); } return $affected_rows; } return parent::affectedRows(); }
/** +---------------------------------------------------------- * 执行语句 针对 INSERT, UPDATE 以及DELETE +---------------------------------------------------------- * @access protected +---------------------------------------------------------- * @param string $str sql指令 +---------------------------------------------------------- * @return integer +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ protected function _execute($str = '') { $this->initConnect(true); if (!$this->_linkID) { return false; } if ($str != '') { $this->queryStr = $str; } if (!$this->autoCommit && $this->isMainIps($this->queryStr)) { $this->startTrans(); } else { //释放前次的查询结果 if ($this->queryID) { $this->free(); } } $this->writeTimes++; $this->W(1); $result = ibase_query($this->_linkID, $this->queryStr); $this->debug(); if (false === $result) { return false; } else { $this->numRows = ibase_affected_rows($this->_linkID); //剑雷 2007.12.28 //$this->lastInsID = mysql_insert_id($this->_linkID); $this->lastInsID = 0; return $this->numRows; } }
/** * Returns number of affected records (tuples) * @return resource The result resource, or <b>FALSE</b> if no more results are available. */ public function getAffectedRows() { return ibase_affected_rows($this->resource); }
</header><!--/header--> <?php include "conexao.php"; $nome = $_POST["nome"]; $email = $_POST["email"]; $assunto = $_POST["assunto"]; $mensagem = $_POST["mensagem"]; $data = date("d.m.Y"); //echo " <br> <br> $nome $email $assunto $mensagem $data "; $consulta = ibase_query("INSERT INTO TB_MENSAGENS VALUES(1,'{$nome}','{$email}','{$assunto}', '{$mensagem}', '{$data}')"); if (ibase_affected_rows() > 0) { echo "\n <section id='about'>\n <div class='container'>\n\n <div class='section-header'>\n <h2 class='section-title text-center wow fadeInDown'>Mensagem Recebida</h2>\n <p class='text-center wow fadeInDown'>Responderemos o mais rápido possível</p>\n </div>\n </div>\n </section><!--/#about-->\n\n <div class='container' align='center'>\n <a class='btn btn-primary btn-block' href='index.html'>Voltar</a>\n </div>\n\n <br>\n <br>\n"; } else { ibase_errcode(); } ?> <section id="cta2"> <div class="container"> <div class="text-center"> <h2 class="wow fadeInUp" data-wow-duration="300ms" data-wow-delay="0ms"><span>EDUC Aluno</span> o App para consultas acadêmicas</h2>
/** * Returns the number of rows affected * * @param resource $result * @param resource $connection * @return mixed MDB2 Error Object or the number of rows affected * @access private */ function _affectedRows($connection, $result = null) { if (null === $connection) { $connection = $this->getConnection(); if (MDB2::isError($connection)) { return $connection; } } return function_exists('ibase_affected_rows') ? @ibase_affected_rows($connection) : 0; }
/** * Returns the number of rows affected by the execution of the * last INSERT, DELETE, or UPDATE statement executed by this * statement object. * * @return int The number of rows affected. * @throws Zend_Db_Statement_Exception */ public function rowCount() { if ($trans = $this->_adapter->getTransaction()) { $num_rows = ibase_affected_rows($trans); } else { $num_rows = ibase_affected_rows($this->_adapter->getConnection()); } if ($num_rows === false) { /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Statement/Frebird/Exception.php'; throw new Zend_Db_Statement_Firebird_Exception(ibase_errmsg()); } return $num_rows; }
/** * @see ILumine_Connection::affected_rows() */ public function affected_rows() { if ($this->state == self::OPEN) { return ibase_affected_rows($this->conn_id); } throw new Lumine_Exception('conexao nao esta aberta', Lumine_Exception::ERRO); }
/** * Returns number of affected rows in previous database operation. If no previous operation exists, * this returns false. * * @return integer Number of affected rows */ function lastAffected() { if ($this->_result) { return ibase_affected_rows($this->connection); } return null; }
/** * Numero de Filas afectadas en un insert, update o delete * * @param resource $result_query * @return int */ public function affected_rows($result_query = '') { if (($numberRows = ibase_affected_rows()) !== false) { return $numberRows; } else { $this->lastError = $this->error(); throw new KumbiaException($this->error()); } return false; }
/** * Executes a prepared statement. * * @param array $params OPTIONAL Values to bind to parameter placeholders. * @return bool * @throws ZendX_Db_Statement_Firebird_Exception */ public function _execute(array $params = null) { if (!$this->_stmtPrepared) { return false; } // if no params were given as an argument to execute(), // then default to the _bindParam array if ($params === null) { $params = $this->_bindParam; } // send $params as input parameters to the statement if ($params) { array_unshift($params, $this->_stmtPrepared); $retval = @call_user_func_array('ibase_execute', $params); } else { // execute the statement $retval = @ibase_execute($this->_stmtPrepared); } $this->_stmtResult = $retval; if ($retval === false) { $last_error = ibase_errmsg(); $this->_stmtRowCount = 0; } //Firebird php ibase extension, auto-commit is not after each call, but at //end of script. Disabled when transaction is active if (!$this->_adapter->getTransaction()) { ibase_commit_ret(); } if ($retval === false) { /** * @see ZendX_Db_Statement_Firebird_Exception */ require_once 'ZendX/Db/Statement/Firebird/Exception.php'; throw new ZendX_Db_Statement_Firebird_Exception("Firebird statement execute error : " . $last_error); } // statements that have no result set do not return metadata if (is_resource($this->_stmtResult)) { // get the column names that will result $this->_keys = array(); $coln = ibase_num_fields($this->_stmtResult); $this->_stmtColumnCount = $coln; for ($i = 0; $i < $coln; $i++) { $col_info = ibase_field_info($this->_stmtResult, $i); $this->_keys[] = $this->_adapter->foldCase($col_info['name']); } // set up a binding space for result variables $this->_values = array_fill(0, count($this->_keys), null); // set up references to the result binding space. // just passing $this->_values in the call_user_func_array() // below won't work, you need references. $refs = array(); foreach ($this->_values as $i => &$f) { $refs[$i] =& $f; } } if ($trans = $this->_adapter->getTransaction()) { $this->_stmtRowCount = ibase_affected_rows($trans); } else { $this->_stmtRowCount = ibase_affected_rows($this->_adapter->getConnection()); } return true; }
/** * Affected Rows * * @return int */ public function affected_rows() { return ibase_affected_rows($this->conn_id); }
/** * Numero de Filas afectadas en un insert, update o delete * * @param resource $result_query * @return int */ public function affected_rows($result_query = NULL) { if (($numberRows = ibase_affected_rows()) !== false) { return $numberRows; } else { throw new KumbiaException($this->error()); } }
function dbi_affected_rows($conn, $res) { if (strcmp($GLOBALS['db_type'], 'mysql') == 0) { return mysql_affected_rows($conn); } elseif (strcmp($GLOBALS['db_type'], 'mysqli') == 0) { return $conn->affected_rows; } elseif (strcmp($GLOBALS['db_type'], 'mssql') == 0) { return mssql_rows_affected($conn); } elseif (strcmp($GLOBALS['db_type'], 'oracle') == 0) { return $GLOBALS['oracle_statement'] >= 0 ? OCIRowCount($GLOBALS['oracle_statement']) : -1; } elseif (strcmp($GLOBALS['db_type'], 'postgresql') == 0) { return pg_affected_rows($res); } elseif (strcmp($GLOBALS['db_type'], 'odbc') == 0) { return odbc_num_rows($res); } elseif (strcmp($GLOBALS['db_type'], 'ibm_db2') == 0) { return db2_num_rows($res); } elseif (strcmp($GLOBALS['db_type'], 'ibase') == 0) { return ibase_affected_rows($conn); } elseif (strcmp($GLOBALS['db_type'], 'sqlite') == 0) { return sqlite_changes($conn); } else { dbi_fatal_error('dbi_free_result (): ' . translate('db_type not defined.')); } }
/** * Execute any statement * * @param string sql * @param bool buffered default TRUE * @return rdbms.ResultSet * @throws rdbms.SQLException */ protected function query0($sql, $buffered = true) { if (!is_resource($this->handle)) { if (!($this->flags & DB_AUTOCONNECT)) { throw new \rdbms\SQLStateException('Not connected'); } $c = $this->connect(); // Check for subsequent connection errors if (false === $c) { throw new \rdbms\SQLStateException('Previously failed to connect'); } } $result = ibase_query($sql, $this->handle); if (false === $result) { $message = 'Statement failed: ' . trim(ibase_errmsg()) . ' @ ' . $this->dsn->getHost(); $code = ibase_errcode(); switch ($code) { case -924: // Connection lost throw new \rdbms\SQLConnectionClosedException($message, $sql); case -913: // Deadlock throw new \rdbms\SQLDeadlockException($message, $sql, $code); default: // Other error throw new \rdbms\SQLStatementFailedException($message, $sql, $code); } } else { if (true === $result) { return new QuerySucceeded(ibase_affected_rows($this->handle)); } else { return new InterBaseResultSet($result, $this->tz); } } }
/** * Return number of affected rows */ function sql_affectedrows() { // PHP 5+ function if (function_exists('ibase_affected_rows')) { return $this->db_connect_id ? @ibase_affected_rows($this->db_connect_id) : false; } else { return $this->affected_rows; } }
/** * Returns the number of rows affected by the last INSERT, UPDATE or DELETE. * * <b>Note:</b> Use the {@link dbi_error()} function to get error information * if the connection fails. * * @param resource $conn The database connection * @param resource $res The database query resource returned from * the {@link dbi_query()} function. * * @return int The number or database rows affected. */ function dbi_affected_rows($conn, $res) { if (strcmp($GLOBALS["db_type"], "mysql") == 0) { return mysql_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { return mysqli_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { return mssql_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { if ($GLOBALS["oracle_statement"] >= 0) { return OCIRowCount($GLOBALS["oracle_statement"]); } else { return -1; } } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { return pg_affected_rows($res); } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { return odbc_num_rows($res); } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { return db2_num_rows($res); } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { return ibase_affected_rows($conn); } else { dbi_fatal_error("dbi_free_result(): db_type not defined."); } } } } } } } } }
public function execute($sql, $data = array()) { if (!$this->is_connected()) { $this->connect(); } if (!is_array($data)) { $data = array(); } $data = array_values($data); foreach ($data as $i => $v) { switch (gettype($v)) { case "boolean": case "integer": $data[$i] = (int) $v; break; case "array": $data[$i] = implode(',', $v); break; case "object": case "resource": $data[$i] = serialize($data[$i]); break; } } array_unshift($data, $sql); $temp = call_user_func_array("ibase_execute", $data); if (!$temp) { throw new Exception('Could not execute query : ' . ibase_errmsg() . ' <' . $sql . '>'); } $this->aff = ibase_affected_rows($this->lnk); return $temp; }