/** * @see Connection::executeUpdate() */ public function executeUpdate($sql) { $this->log("executeUpdate(): {$sql}"); $this->lastExecutedQuery = $sql; $this->numQueriesExecuted++; return $this->childConnection->executeUpdate($sql); }
/** * Executes the SQL INSERT, UPDATE, or DELETE statement in this PreparedStatement object. * * @param string $sql This method may optionally be called with the SQL statement. * @return int Number of affected rows (or 0 for drivers that return nothing). * @throws SQLException if a database access error occurs. */ public function executeUpdate($sql) { if ($this->resultSet) { $this->resultSet->close(); } $this->resultSet = null; $this->updateCount = $this->conn->executeUpdate($sql); return $this->updateCount; }
public function tearDown() { ActiveRecordModel::rollback(); foreach ($this->getUsedSchemas() as $table) { ActiveRecord::removeClassFromPool($table); $this->db->executeUpdate("ALTER TABLE {$table} AUTO_INCREMENT=" . $this->autoincrements[$table]); } self::getApplication()->setRequest(clone $this->originalRequest); }
/** * @see Connection::executeUpdate() */ public function executeUpdate($sql) { $this->lastExecutedQuery = $sql; $this->numQueriesExecuted++; $startTime = microtime(true); $res = $this->childConnection->executeUpdate($sql); $endTime = microtime(true); $time = $endTime - $startTime; $this->log("executeUpdate|{$time}|{$sql}"); return $res; }
/** * Executes the SQL INSERT, UPDATE, or DELETE statement in this PreparedStatement object. * * @param array $params Parameters that will be set using PreparedStatement::set() before query is executed. * @return int Number of affected rows (or 0 for drivers that return nothing). * @throws SQLException if a database access error occurs. */ public function executeUpdate($params = null) { foreach ((array) $params as $i => $param) { $this->set($i + 1, $param); unset($i, $param); } unset($params); if ($this->resultSet) { $this->resultSet->close(); } $this->resultSet = null; // reset $sql = $this->replaceParams(); $this->updateCount = $this->conn->executeUpdate($sql); return $this->updateCount; }
/** * Executes the SQL INSERT, UPDATE, or DELETE statement in this PreparedStatement object. * * @param array $params Parameters that will be set using PreparedStatement::set() before query is executed. * @return int Number of affected rows (or 0 for drivers that return nothing). * @throws SQLException if a database access error occurs. */ public function executeUpdate($params = null) { if ($params) { for ($i = 0, $cnt = count($params); $i < $cnt; $i++) { $this->set($i + 1, $params[$i]); } } if ($this->resultSet) { $this->resultSet->close(); } $this->resultSet = null; // reset $sql = $this->replaceParams(); $this->updateCount = $this->conn->executeUpdate($sql); return $this->updateCount; }
/** * @see Connection::executeUpdate() **/ public function executeUpdate($sql) { $this->lastExecutedQuery = $sql; $this->numQueriesExecuted++; $boolLog = sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled') || nyProfiler::getInstance()->isStarted(); $elapsedTime = 0; if ($boolLog) { $sqlTimer = sfTimerManager::getTimer('Database'); $timer = new sfTimer(); } // endif $intResult = $this->childConnection->executeUpdate($sql); if ($boolLog) { $sqlTimer->addTime(); $elapsedTime = $timer->getElapsedTime(); } // endif $this->log(sprintf("{sfCreole} executeUpdate(): [%.2f ms] %s", $elapsedTime * 1000, $sql), true); return $intResult; }
public function testRollback() { $exch = DriverTestManager::getExchange('RecordCount'); $count_sql = $exch->getSql(); $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM); $rs->next(); $total = $rs->getInt(1); // $this->assertEquals((int) $exch->getResult(), $total); $this->conn->setAutoCommit(false); // not sure exactly how to test this yet ... $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN1'); $deleted1 = $this->conn->executeUpdate($exch->getSql()); $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN2'); $deleted2 = $this->conn->executeUpdate($exch->getSql()); $this->conn->rollback(); // compare the actual total w/ what we expect $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM); $rs->next(); $new_actual_total = $rs->getInt(1); $this->assertEquals($total, $new_actual_total, 0, "Failed to find correct (same) num of records in table after rollback()."); $this->conn->setAutoCommit(true); }