diff options
| author | BohwaZ <bohwaz@users.noreply.github.com> | 2018-08-01 17:45:20 -0400 | 
|---|---|---|
| committer | Adam Baratz <adambaratz@php.net> | 2018-08-01 17:45:20 -0400 | 
| commit | 6f9ebe677bf31d0c64046f18e6b0ac75340cb93e (patch) | |
| tree | fd0049c804cb37a7558c3ee8a42485d12a551d82 /ext/pdo_sqlite/sqlite_statement.c | |
| parent | 1a303f1a2b6ed8853fea3a2079999eef7f462d86 (diff) | |
| download | php-git-6f9ebe677bf31d0c64046f18e6b0ac75340cb93e.tar.gz | |
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.
Diffstat (limited to 'ext/pdo_sqlite/sqlite_statement.c')
| -rw-r--r-- | ext/pdo_sqlite/sqlite_statement.c | 24 | 
1 files changed, 23 insertions, 1 deletions
| diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index c82e2d34eb..4a9d2462bf 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -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 | 
