SQLite3::changes
(PHP 5 >= 5.3.0)
SQLite3::changes — Returns the number of database rows that were changed (or inserted or deleted) by the most recent SQL statement
Описание
public int SQLite3::changes
( void
)
Returns the number of database rows that were changed (or inserted or deleted) by the most recent SQL statement.
Список параметров
У этой функции нет параметров.
Возвращаемые значения
Returns an integer value corresponding to the number of database rows changed (or inserted or deleted) by the most recent SQL statement.
Примеры
Пример #1 SQLite3::changes() example
<?php
$db = new SQLite3('mysqlitedb.db');
$query = $db->exec('UPDATE counter SET views=0 WHERE page="test"');
if ($query) {
echo 'Number of rows modified: ', $db->changes();
}
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- SQLite3
- Функция SQLite3::busyTimeout() - Sets the busy connection handler
- SQLite3::changes
- Функция SQLite3::close() - Closes the database connection
- Функция SQLite3::__construct() - Instantiates an SQLite3 object and opens an SQLite 3 database
- Функция SQLite3::createAggregate() - Registers a PHP function for use as an SQL aggregate function
- Функция SQLite3::createCollation() - Registers a PHP function for use as an SQL collating function
- Функция SQLite3::createFunction() - Registers a PHP function for use as an SQL scalar function
- SQLite3::enableExceptions
- Функция SQLite3::escapeString() - Returns a string that has been properly escaped
- Функция SQLite3::exec() - Executes a result-less query against a given database
- Функция SQLite3::lastErrorCode() - Returns the numeric result code of the most recent failed SQLite request
- Функция SQLite3::lastErrorMsg() - Returns English text describing the most recent failed SQLite request
- Функция SQLite3::lastInsertRowID() - Returns the row ID of the most recent INSERT into the database
- Функция SQLite3::loadExtension() - Attempts to load an SQLite extension library
- Функция SQLite3::open() - Opens an SQLite database
- SQLite3::openBlob
- Функция SQLite3::prepare() - Подготавливает SQL-запрос для выполнения
- Функция SQLite3::query() - Выполняет SQL-запрос
- Функция SQLite3::querySingle() - Executes a query and returns a single result
- Функция SQLite3::version() - Returns the SQLite3 library version as a string constant and as a number
Коментарии
There is an issue that may be meant or not, but in my case is annoying. If you have have a schema like the following:
[code]
pragma foreign_key = on;
create table parent (
id integer,
a varchar,
primary key (id asc)
);
create table child (
id integer,
b varchar,
a integer,
primary key (id asc),
foreign key (a) references a (id) on delete cascade on update cascade
);
[/code]
When you try to delete a parent row (delete from parent where parent.id=?) it deletes all the childs referenced to this parent, but the method SQLite3::changes() is still returning 1, as if it only have deleted the parent.