本文整理汇总了PHP中Connection::executeUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::executeUpdate方法的具体用法?PHP Connection::executeUpdate怎么用?PHP Connection::executeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::executeUpdate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeUpdate
/**
* @see Connection::executeUpdate()
*/
public function executeUpdate($sql)
{
$this->log("executeUpdate(): {$sql}");
$this->lastExecutedQuery = $sql;
$this->numQueriesExecuted++;
return $this->childConnection->executeUpdate($sql);
}
示例2: executeUpdate
/**
* 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;
}
示例3: tearDown
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);
}
示例4: executeUpdate
/**
* @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;
}
示例5: executeUpdate
/**
* 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;
}
示例6: executeUpdate
/**
* 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;
}
示例7: executeUpdate
/**
* @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;
}
示例8: testRollback
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);
}