本文整理汇总了PHP中sqlite_changes函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_changes函数的具体用法?PHP sqlite_changes怎么用?PHP sqlite_changes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_changes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exec
public function exec(&$statement)
{
if (@sqlite_exec($this->link, $statement)) {
return sqlite_changes($this->link);
}
return false;
}
示例2: SqliteResultSet
/**
* Constructs a new SqliteResultSet
*
* \param $sql
* The sql query to execute.
*
* \param $backend
* A reference to the used backend.
*/
function SqliteResultSet($sql, &$backend)
{
assert('is_string($sql)');
$this->sql = $sql;
$this->backend =& $backend;
$this->rs = sqlite_query($this->backend->handle, $sql) or trigger_error(sprintf('Query failed (%s)', sqlite_error_string(sqlite_last_error($this->backend->handle))), E_USER_ERROR);
$this->rows_affected = sqlite_changes($this->backend->handle);
}
示例3: _doExec
protected function _doExec($query)
{
if ($qI = sqlite_query($query, $this->_connection)) {
return sqlite_changes($this->_connection);
} else {
throw new jException('jelix~db.error.query.bad', sqlite_error_string($this->_connection) . '(' . $query . ')');
}
}
示例4: sql_affected_rows
function sql_affected_rows()
{
global $con;
if (DB_TYPE == 'mysql') {
$sql = mysql_affected_rows();
} elseif (DB_TYPE == 'sqlite') {
$sql = sqlite_changes($con);
}
return $sql;
}
示例5: getLength
public function getLength()
{
if ($this->r === true) {
return sqlite_changes($this->r);
} else {
if ($this->r === false) {
return 0;
}
}
return sqlite_num_rows($this->r);
}
示例6: exec
public function exec($sql, $connResource)
{
if (empty($sql)) {
return 0;
}
sqlite_exec($connResource, $sql);
// echo '<pre>';
// print_r(debug_backtrace());
// debug_print_backtrace();
// echo '</pre>';
// delete from table 结果为0,原因未知。
// 使用 delete from table where 1 能返回正确结果
return sqlite_changes($connResource);
}
示例7: _query
protected function _query($sql)
{
$result = sqlite_query($this->_connection, $sql);
$error = sqlite_last_error($this->_connection);
$this->_errorHandler($error, $error != 0 ? sqlite_error_string($error) : '');
if ($result && $this->queryHasResultSet($sql)) {
$this->_numRows = sqlite_num_rows($result);
$resultObject = $this->createRecordsetObject();
$resultObject->setResult($result);
} else {
$this->_numRows = sqlite_changes($this->_connection);
$resultObject = $this->createResultObject();
}
return $resultObject;
}
示例8: __construct
/**
* Run a query
*
* @param string $sql
* @param resource $connection DB Connection
* @throws Exception MySQL error
*/
public function __construct($sql, $connection)
{
parent::__construct($sql);
$this->connection = $connection;
$errorMessage = '';
// Overwritten by sqlite_query
$resource = sqlite_query($this->connection, $sql, SQLITE_ASSOC, $errorMessage);
if (false === $resource) {
throw new Exception('SQLite Error: ' . $errorMessage);
} else {
$this->resource = $resource;
$this->setNumberOfRows(sqlite_num_rows($resource));
$this->columns = $this->getColumnTypes();
$this->rowsAffected = sqlite_changes($this->connection);
$this->lastId = sqlite_last_insert_rowid($this->connection);
}
}
示例9: execute
function execute($db, $sql)
{
if (IS_SQLITE3) {
if ($db->query($sql)) {
return $db->changes();
} else {
return false;
}
} else {
if (sqlite_query($db, $sql, 0666, $error)) {
//echo "<font color='red'>1.".$error."</font>";
return sqlite_changes($db);
} else {
//echo "<font color='red'>2.".$error."</font>";
return false;
}
}
}
示例10: query
/**
* SQLite::query()
*
* @param mixed $sql
* @return
*/
public function query($sql)
{
$data = array();
$i = 0;
$err_msg = "";
$result = sqlite_query($this->conn, $sql, SQLITE_ASSOC, $err_msg);
if ($result == false) {
throw new Exception("{$sql}<br />执行错误:" . $err_msg);
} else {
while ($arr = sqlite_fetch_array($result, SQLITE_ASSOC)) {
$data[$i++] = $arr;
}
}
if (count($data) > 0) {
return $data;
} else {
return sqlite_changes($this->conn);
}
}
示例11: getAffectedRows
function getAffectedRows()
{
return sqlite_changes($this->conn);
}
示例12: affectedRows
/**
* Gets the number of rows affected by a query.
*
* @return number of rows affected by the last query
*/
function affectedRows()
{
return @sqlite_changes($this->connection);
}
示例13: __construct
public function __construct($sql, $connection_handle, $result_set_handle)
{
parent::__construct($sql, $connection_handle, $result_set_handle);
$this->n_rows = sqlite_num_rows($result_set_handle);
$this->n_rows_affected = sqlite_changes($connection_handle);
}
示例14: setAffectedRows
/**
* Sets the number of rows affected by the query
*
* @param fResult $result The result object for the query
* @param mixed $resource Only applicable for `ibm_db2`, `pdo`, `oci8` and `sqlsrv` extentions or `mysqli` prepared statements - this is either the `PDOStatement` object, `mysqli_stmt` object or the `oci8` or `sqlsrv` resource
* @return void
*/
private function setAffectedRows($result, $resource = NULL)
{
if ($this->extension == 'ibm_db2') {
$insert_update_delete = preg_match('#^\\s*(INSERT|UPDATE|DELETE)\\b#i', $result->getSQL());
$result->setAffectedRows(!$insert_update_delete ? 0 : db2_num_rows($resource));
} elseif ($this->extension == 'mssql') {
$affected_rows_result = mssql_query('SELECT @@ROWCOUNT AS rows', $this->connection);
$result->setAffectedRows((int) mssql_result($affected_rows_result, 0, 'rows'));
} elseif ($this->extension == 'mysql') {
$result->setAffectedRows(mysql_affected_rows($this->connection));
} elseif ($this->extension == 'mysqli') {
if (is_object($resource)) {
$result->setAffectedRows($resource->affected_rows);
} else {
$result->setAffectedRows(mysqli_affected_rows($this->connection));
}
} elseif ($this->extension == 'oci8') {
$result->setAffectedRows(oci_num_rows($resource));
} elseif ($this->extension == 'pgsql') {
$result->setAffectedRows(pg_affected_rows($result->getResult()));
} elseif ($this->extension == 'sqlite') {
$result->setAffectedRows(sqlite_changes($this->connection));
} elseif ($this->extension == 'sqlsrv') {
$result->setAffectedRows(sqlsrv_rows_affected($resource));
} elseif ($this->extension == 'pdo') {
// This fixes the fact that rowCount is not reset for non INSERT/UPDATE/DELETE statements
try {
if (!$resource || !$resource->fetch()) {
throw new PDOException();
}
$result->setAffectedRows(0);
} catch (PDOException $e) {
// The SQLite PDO driver seems to return 1 when no rows are returned from a SELECT statement
if ($this->type == 'sqlite' && $this->extension == 'pdo' && preg_match('#^\\s*SELECT#i', $result->getSQL())) {
$result->setAffectedRows(0);
} elseif (!$resource) {
$result->setAffectedRows(0);
} else {
$result->setAffectedRows($resource->rowCount());
}
}
}
}
示例15: rowCount
public function rowCount()
{
return sqlite_changes($this->_link);
}