Skip to content

Commit afc25f4

Browse files
authored
Merge pull request #14 from pandanotabear/main
feat: bindNamed and bindPositional
2 parents 036b0f1 + a18cc9c commit afc25f4

6 files changed

+890
-173
lines changed

libsql_php_extension.stubs.php

+65-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,32 @@ public function __construct(string $conn_id, string $sql) {}
2424
*/
2525
public function finalize() {}
2626

27+
/**
28+
* Binds a value to a named parameter in the prepared statement.
29+
*
30+
* @param array<string, mixed> $parameters The parameters to bind.
31+
*
32+
* @return void
33+
*/
34+
public function bindNamed(array $parameters) {}
35+
36+
/**
37+
* Binds a value to a positionalparameter in the prepared statement.
38+
*
39+
* @param array<mixed> $parameters The value to bind.
40+
*
41+
* @return void
42+
*/
43+
public function bindPositional(array $parameters) {}
44+
2745
/**
2846
* Executes the prepared statement with given parameters.
2947
*
3048
* @param array $parameters The parameters for the statement.
3149
*
3250
* @return int The number of affected rows.
3351
*/
34-
public function execute(array $parameters) {}
52+
public function execute(array $parameters = []) {}
3553

3654
/**
3755
* Executes the prepared statement and retrieves the result set.
@@ -377,6 +395,52 @@ public function changes() {}
377395
*/
378396
public function isAutocommit() {}
379397

398+
/**
399+
* Retrieves the number of rows changed by the last SQL statement.
400+
*
401+
* ## Example Usage
402+
*
403+
* ```
404+
* // Create a new LibSQL instance
405+
* $db = new LibSQL("libsql:dbname=database.db");
406+
*
407+
* $stmt = "UPDATE users SET age = 28 WHERE id = 1";
408+
* $db->execute($stmt);
409+
*
410+
* // Retrieve the number of rows changed
411+
* $changes = $db->totalChanges();
412+
* echo "Number of Rows Changed: " . $changes;
413+
*
414+
* $db->close();
415+
* ```
416+
*
417+
* @return int The total number of rows changed.
418+
*/
419+
public function totalChanges() {}
420+
421+
/**
422+
* Retrieves the ID of the last inserted row.
423+
*
424+
* ## Example Usage
425+
*
426+
* ```
427+
* // Create a new LibSQL instance
428+
* $db = new LibSQL("libsql:dbname=database.db");
429+
*
430+
* $stmt = "INSERT INTO users (name, age) VALUES ('John Doe', 30)";
431+
* $db->execute($stmt);
432+
*
433+
* // Retrieve the ID of the last inserted row
434+
* $id = $db->lastInsertedId();
435+
* echo "Last inserted row ID: " . $id;
436+
*
437+
* $db->close();
438+
* ```
439+
*
440+
* @return int The ID of the last inserted row.
441+
*/
442+
public function lastInsertedId() {}
443+
380444
/**
381445
* Executes an SQL statement on the database.
382446
*

0 commit comments

Comments
 (0)