Skip to content

Sqlite3 busy #18843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ PHP 8.5 UPGRADE NOTES
. ReflectionConstant::getAttributes() was introduced.
RFC: https://wiki.php.net/rfc/attributes-on-constants

- Sqlite:
. Sqlite3Stmt::busy to check if a statement had been fetched
but not completely.

- Standard:
. Added array_first() and array_last().
RFC: https://wiki.php.net/rfc/array_first_last
Expand Down
17 changes: 17 additions & 0 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,23 @@ PHP_METHOD(SQLite3Stmt, readOnly)
}
/* }}} */

PHP_METHOD(SQLite3Stmt, busy)
{
php_sqlite3_stmt *stmt_obj;
zval *object = ZEND_THIS;
stmt_obj = Z_SQLITE3_STMT_P(object);

ZEND_PARSE_PARAMETERS_NONE();

SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3);
SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt);

if (sqlite3_stmt_busy(stmt_obj->stmt)) {
RETURN_TRUE;
}
RETURN_FALSE;
}

/* bind parameters to a statement before execution */
static int php_sqlite3_bind_params(php_sqlite3_stmt *stmt_obj) /* {{{ */
{
Expand Down
2 changes: 2 additions & 0 deletions ext/sqlite3/sqlite3.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ public function readOnly(): bool {}

/** @tentative-return-type */
public function reset(): bool {}

public function busy(): bool {}
}

/** @not-serializable */
Expand Down
7 changes: 6 additions & 1 deletion ext/sqlite3/sqlite3_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions ext/sqlite3/tests/sqlite3_stmt_busy.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
SQLite3_stmt::busy
--EXTENSIONS--
sqlite3
--SKIPIF--
<?php
$version = SQLite3::version();
if ($version['versionNumber'] < 3007004) die("skip");
?>
--FILE--
<?php

require_once(__DIR__ . '/new_db.inc');
$db->exec('CREATE TABLE test_busy (a string);');
$db->exec('INSERT INTO test_busy VALUES ("interleaved"), ("statements")');
$st = $db->prepare('SELECT a FROM test_busy');
var_dump($st->busy());
$r = $st->execute();
$r->fetchArray();
var_dump($st->busy());
?>
--EXPECT--
bool(false)
bool(true)