Skip to content

Commit

Permalink
Merge pull request #14 from pandanotabear/main
Browse files Browse the repository at this point in the history
feat: bindNamed and bindPositional
  • Loading branch information
darkterminal authored Jan 6, 2025
2 parents 036b0f1 + a18cc9c commit afc25f4
Show file tree
Hide file tree
Showing 6 changed files with 890 additions and 173 deletions.
66 changes: 65 additions & 1 deletion libsql_php_extension.stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,32 @@ public function __construct(string $conn_id, string $sql) {}
*/
public function finalize() {}

/**
* Binds a value to a named parameter in the prepared statement.
*
* @param array<string, mixed> $parameters The parameters to bind.
*
* @return void
*/
public function bindNamed(array $parameters) {}

/**
* Binds a value to a positionalparameter in the prepared statement.
*
* @param array<mixed> $parameters The value to bind.
*
* @return void
*/
public function bindPositional(array $parameters) {}

/**
* Executes the prepared statement with given parameters.
*
* @param array $parameters The parameters for the statement.
*
* @return int The number of affected rows.
*/
public function execute(array $parameters) {}
public function execute(array $parameters = []) {}

/**
* Executes the prepared statement and retrieves the result set.
Expand Down Expand Up @@ -377,6 +395,52 @@ public function changes() {}
*/
public function isAutocommit() {}

/**
* Retrieves the number of rows changed by the last SQL statement.
*
* ## Example Usage
*
* ```
* // Create a new LibSQL instance
* $db = new LibSQL("libsql:dbname=database.db");
*
* $stmt = "UPDATE users SET age = 28 WHERE id = 1";
* $db->execute($stmt);
*
* // Retrieve the number of rows changed
* $changes = $db->totalChanges();
* echo "Number of Rows Changed: " . $changes;
*
* $db->close();
* ```
*
* @return int The total number of rows changed.
*/
public function totalChanges() {}

/**
* Retrieves the ID of the last inserted row.
*
* ## Example Usage
*
* ```
* // Create a new LibSQL instance
* $db = new LibSQL("libsql:dbname=database.db");
*
* $stmt = "INSERT INTO users (name, age) VALUES ('John Doe', 30)";
* $db->execute($stmt);
*
* // Retrieve the ID of the last inserted row
* $id = $db->lastInsertedId();
* echo "Last inserted row ID: " . $id;
*
* $db->close();
* ```
*
* @return int The ID of the last inserted row.
*/
public function lastInsertedId() {}

/**
* Executes an SQL statement on the database.
*
Expand Down
Loading

0 comments on commit afc25f4

Please sign in to comment.