mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add \PDO::SQLITE_ATTR_READONLY_STATEMENT
This attribute is a boolean value. It is taken from the return value of sqlite3_stmt_readonly(), indicating if and only if the prepared statement makes no direct changes to the content of the database.
This commit is contained in:
parent
1a303f1a2b
commit
6f9ebe677b
4 changed files with 45 additions and 1 deletions
|
@ -350,6 +350,28 @@ static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int pdo_sqlite_stmt_get_attribute(pdo_stmt_t *stmt, zend_long attr, zval *val)
|
||||
{
|
||||
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
|
||||
|
||||
switch (attr) {
|
||||
case PDO_SQLITE_ATTR_READONLY_STATEMENT:
|
||||
ZVAL_FALSE(val);
|
||||
|
||||
#if SQLITE_VERSION_NUMBER >= 3007004
|
||||
if (sqlite3_stmt_readonly(S->stmt)) {
|
||||
ZVAL_TRUE(val);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct pdo_stmt_methods sqlite_stmt_methods = {
|
||||
pdo_sqlite_stmt_dtor,
|
||||
pdo_sqlite_stmt_execute,
|
||||
|
@ -358,7 +380,7 @@ const struct pdo_stmt_methods sqlite_stmt_methods = {
|
|||
pdo_sqlite_stmt_get_col,
|
||||
pdo_sqlite_stmt_param_hook,
|
||||
NULL, /* set_attr */
|
||||
NULL, /* get_attr */
|
||||
pdo_sqlite_stmt_get_attribute, /* get_attr */
|
||||
pdo_sqlite_stmt_col_meta,
|
||||
NULL, /* next_rowset */
|
||||
pdo_sqlite_stmt_cursor_closer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue