From 43b35584040098104a53b15a14186aebe7e9db9e Mon Sep 17 00:00:00 2001 From: Kenneth Schwartz Date: Fri, 14 Jan 2005 05:42:48 +0000 Subject: [PATCH] Add/Update examples (incorp. user notes) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@177193 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../sqlite/functions/sqlite-busy-timeout.xml | 20 +++++++++++- reference/sqlite/functions/sqlite-changes.xml | 29 ++++++++++++++++- reference/sqlite/functions/sqlite-exec.xml | 29 ++++++++++++++++- reference/sqlite/functions/sqlite-factory.xml | 31 ++++++++++++++++--- .../sqlite/functions/sqlite-num-rows.xml | 24 +++++++++++++- reference/sqlite/functions/sqlite-open.xml | 3 +- 6 files changed, 126 insertions(+), 10 deletions(-) diff --git a/reference/sqlite/functions/sqlite-busy-timeout.xml b/reference/sqlite/functions/sqlite-busy-timeout.xml index 2d5cab8344..cf19b69fa2 100644 --- a/reference/sqlite/functions/sqlite-busy-timeout.xml +++ b/reference/sqlite/functions/sqlite-busy-timeout.xml @@ -1,5 +1,5 @@ - + sqlite_busy_timeout @@ -34,6 +34,24 @@ PHP sets the default busy timeout to be 60 seconds when the database is opened. + + + <function>sqlite_busy_timeout</function> example + +busyTimeout(10000); // 10 seconds +$dbhandle->busyTimeout(0); // disable +?>]]> + + + There are one thousand (1000) milliseconds in one second. diff --git a/reference/sqlite/functions/sqlite-changes.xml b/reference/sqlite/functions/sqlite-changes.xml index 411a142577..997b8361fc 100644 --- a/reference/sqlite/functions/sqlite-changes.xml +++ b/reference/sqlite/functions/sqlite-changes.xml @@ -1,5 +1,5 @@ - + sqlite_changes @@ -28,6 +28,33 @@ statement executed against the dbhandle database handle. + + + <function>sqlite_changes</function> example + +query("UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'"); +if (!$query) { + exit('Error in query.'); +} else { + echo 'Number of rows modified: ', $dbhandle->changes(); +} + +?>]]> + + + See also sqlite_num_rows. diff --git a/reference/sqlite/functions/sqlite-exec.xml b/reference/sqlite/functions/sqlite-exec.xml index 959f5586fa..bf0c5f2268 100644 --- a/reference/sqlite/functions/sqlite-exec.xml +++ b/reference/sqlite/functions/sqlite-exec.xml @@ -1,5 +1,5 @@ - + sqlite_exec @@ -42,6 +42,33 @@ loaded from a file or have embedded in a script. + + + <function>sqlite_exec</function> example + +exec("UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'"); +if (!$query) { + exit('Error in query.'); +} else { + echo 'Number of rows modified: ', $dbhandle->changes(); +} + +?>]]> + + + &sqlite.param-compat; See also sqlite_query, diff --git a/reference/sqlite/functions/sqlite-factory.xml b/reference/sqlite/functions/sqlite-factory.xml index d2494b63b3..fd30cb8917 100755 --- a/reference/sqlite/functions/sqlite-factory.xml +++ b/reference/sqlite/functions/sqlite-factory.xml @@ -1,9 +1,9 @@ - + sqlite_factory - Opens a SQLite database and returns an SQLiteDatabase object + Opens a SQLite database and returns a SQLiteDatabase object Description @@ -13,14 +13,35 @@ intmode stringerror_message + + Returns a SQLiteDatabase object on success, &null; on error. + sqlite_factory behaves similarly to sqlite_open in that it opens an SQLite database or attempts to create it if it does not exist. However, a SQLiteDatabase object is - returned rather than a procedural resource. Please see the - sqlite_open reference page for usage and caveats. - + returned rather than a resource. Please see the + sqlite_open reference page for further usage and caveats. + + + + <function>sqlite_factory</function> example + +query('SELECT user_id, username FROM users'); + +/* functionally equivalent to: */ + +$dbhandle = new SQLiteDatabase('sqlitedb'); +$dbhandle->query('SELECT user_id, username FROM users'); + +?>]]> + + + See also sqlite_open and sqlite_popen. diff --git a/reference/sqlite/functions/sqlite-num-rows.xml b/reference/sqlite/functions/sqlite-num-rows.xml index 95e8ad522f..1b0700fa16 100644 --- a/reference/sqlite/functions/sqlite-num-rows.xml +++ b/reference/sqlite/functions/sqlite-num-rows.xml @@ -1,5 +1,5 @@ - + sqlite_num_rows @@ -25,6 +25,28 @@ set. &sqlite.no-unbuffered; + + + <function>sqlite_num_rows</function> example + +query("SELECT * FROM mytable WHERE name='John Doe'"); +$rows = $result->numRows(); + +echo "Number of rows: $rows"; +?]]> + + + See also sqlite_changes and sqlite_query. diff --git a/reference/sqlite/functions/sqlite-open.xml b/reference/sqlite/functions/sqlite-open.xml index ac583141cf..32f3683357 100644 --- a/reference/sqlite/functions/sqlite-open.xml +++ b/reference/sqlite/functions/sqlite-open.xml @@ -1,5 +1,5 @@ - + sqlite_open @@ -103,6 +103,7 @@ if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) { See also sqlite_popen, + sqlite_factory, sqlite_close and sqlite_query.