From eb2d8b37a7e7bac7a7b2fe5e7a162186e9bafa06 Mon Sep 17 00:00:00 2001 From: Philip Olson Date: Mon, 21 Jul 2003 16:44:20 +0000 Subject: [PATCH] Unify the database handle name as dbhandle, instead of db or database. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@135559 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../sqlite/functions/sqlite-array-query.xml | 6 ++--- .../sqlite/functions/sqlite-busy-timeout.xml | 9 ++++--- reference/sqlite/functions/sqlite-changes.xml | 7 +++--- reference/sqlite/functions/sqlite-close.xml | 4 +-- .../functions/sqlite-create-aggregate.xml | 14 +++++------ .../functions/sqlite-create-function.xml | 25 ++++++++++++------- .../sqlite/functions/sqlite-fetch-single.xml | 9 ++++--- .../sqlite/functions/sqlite-last-error.xml | 6 ++--- .../functions/sqlite-last-insert-rowid.xml | 6 ++--- reference/sqlite/functions/sqlite-open.xml | 4 +-- reference/sqlite/functions/sqlite-query.xml | 9 ++++--- .../functions/sqlite-unbuffered-query.xml | 6 ++--- 12 files changed, 59 insertions(+), 46 deletions(-) diff --git a/reference/sqlite/functions/sqlite-array-query.xml b/reference/sqlite/functions/sqlite-array-query.xml index cecd42e613..e4bb49a7e8 100644 --- a/reference/sqlite/functions/sqlite-array-query.xml +++ b/reference/sqlite/functions/sqlite-array-query.xml @@ -1,5 +1,5 @@ - + sqlite_array_query @@ -9,7 +9,7 @@ Description arraysqlite_array_query - resourcedb + resourcedbhandle stringquery intresult_type booldecode_binary @@ -27,7 +27,7 @@ - + sqlite_busy_timeout Set busy timeout duration, or disable busy handlers. @@ -8,12 +8,12 @@ Description voidsqlite_busy_timeout - resourcedatabase + resourcedbhandle intmilliseconds Set the maximum time that sqlite will wait for a - database + dbhandle to become ready for use to milliseconds. If milliseconds is 0, busy handlers will be disabled and sqlite will return immediately with a @@ -29,6 +29,9 @@ There are one thousand (1000) milliseconds in one second. + + See also sqlite_open. + + sqlite_changes @@ -12,11 +12,12 @@ Description intsqlite_changes - resourcedb + resourcedbhandle Returns the numbers of rows that were changed by the most recent SQL - statement executed against the database db. + statement executed against the dbhandle database + handle. See also sqlite_num_rows. diff --git a/reference/sqlite/functions/sqlite-close.xml b/reference/sqlite/functions/sqlite-close.xml index c70cbf23c6..5ff102642a 100644 --- a/reference/sqlite/functions/sqlite-close.xml +++ b/reference/sqlite/functions/sqlite-close.xml @@ -1,5 +1,5 @@ - + sqlite_close @@ -9,7 +9,7 @@ Description voidsqlite_close - resourcedatabase + resourcedbhandle Closes the given database handle. diff --git a/reference/sqlite/functions/sqlite-create-aggregate.xml b/reference/sqlite/functions/sqlite-create-aggregate.xml index bf0941e2a9..a42896969e 100644 --- a/reference/sqlite/functions/sqlite-create-aggregate.xml +++ b/reference/sqlite/functions/sqlite-create-aggregate.xml @@ -1,5 +1,5 @@ - + sqlite_create_aggregate @@ -9,7 +9,7 @@ Description boolsqlite_create_aggregate - resourcedb + resourcedbhandle stringfunction_name mixedstep_func mixedfinalize_func @@ -49,11 +49,11 @@ $data = array( 'nine' 'ten' ); -$db = sqlite_open(':memory:'); -sqlite_query($db, "CREATE TABLE strings(a)"); +$dbhandle = sqlite_open(':memory:'); +sqlite_query($dbhandle, "CREATE TABLE strings(a)"); foreach ($data as $str) { $str = sqlite_escape_string($str); - sqlite_query($db, "INSERT INTO strings VALUES ('$str')"); + sqlite_query($dbhandle, "INSERT INTO strings VALUES ('$str')"); } function max_len_step(&$context, $string) { @@ -66,9 +66,9 @@ function max_len_finalize(&$context) { return $context; } -sqlite_create_aggregate($db, 'max_len', 'max_len_step', 'max_len_finalize'); +sqlite_create_aggregate($dbhandle, 'max_len', 'max_len_step', 'max_len_finalize'); -var_dump(sqlite_array_query($db, 'SELECT max_len(a) from strings')); +var_dump(sqlite_array_query($dbhandle, 'SELECT max_len(a) from strings')); ?> ]]> diff --git a/reference/sqlite/functions/sqlite-create-function.xml b/reference/sqlite/functions/sqlite-create-function.xml index c0cac6044b..f9e71029df 100644 --- a/reference/sqlite/functions/sqlite-create-function.xml +++ b/reference/sqlite/functions/sqlite-create-function.xml @@ -1,5 +1,5 @@ - + sqlite_create_function @@ -11,7 +11,7 @@ Description boolsqlite_create_function - resourcedb + resourcedbhandle stringfunction_name mixedcallback intnum_args @@ -23,9 +23,9 @@ statements. - db specifies the database handle that you wish to - extend, function_name specifies the name of the - function that you will use in your SQL statements, + dbhandle specifies the database handle that you + wish to extend, function_name specifies the name + of the function that you will use in your SQL statements, callback is any valid PHP callback to specify a PHP function that should be called to handle the SQL function. The optional parameter num_args is used as a hint @@ -47,9 +47,16 @@ function md5_and_reverse($string) { return strrev(md5($string)); } -sqlite_create_function($db, 'md5rev', 'md5_and_reverse', 1); - -$rows = sqlite_array_query($db, 'SELECT md5rev(filename) from files'); +if ($dbhandle = sqlite_open('mysqlitedb', 0666, $sqliteerror)) { + + sqlite_create_function($dbhandle, 'md5rev', 'md5_and_reverse', 1); + + $sql = 'SELECT md5rev(filename) FROM files'; + $rows = sqlite_array_query($dbhandle, $sql); +} else { + echo 'Error opening sqlite db: ' . $sqliteerror; + exit; +} ?> ]]> @@ -76,7 +83,7 @@ $rows = sqlite_array_query($db, 'SELECT md5rev(filename) from files'); ]]> diff --git a/reference/sqlite/functions/sqlite-fetch-single.xml b/reference/sqlite/functions/sqlite-fetch-single.xml index b3111b372f..e76cad3c5e 100644 --- a/reference/sqlite/functions/sqlite-fetch-single.xml +++ b/reference/sqlite/functions/sqlite-fetch-single.xml @@ -1,5 +1,5 @@ - + sqlite_fetch_single @@ -28,15 +28,16 @@ 0) { echo sqlite_fetch_single($res); // 42 } - sqlite_close($db); + sqlite_close($dbhandle); } ?> ]]> diff --git a/reference/sqlite/functions/sqlite-last-error.xml b/reference/sqlite/functions/sqlite-last-error.xml index 974c04a0b4..6c1354dec9 100644 --- a/reference/sqlite/functions/sqlite-last-error.xml +++ b/reference/sqlite/functions/sqlite-last-error.xml @@ -1,5 +1,5 @@ - + sqlite_last_error @@ -9,11 +9,11 @@ Description intsqlite_last_error - resourcedb + resourcedbhandle Returns the error code from the last operation performed on - db, the database handle. A human readable + dbhandle, the database handle. A human readable description of the error code can be retrieved using sqlite_error_string. diff --git a/reference/sqlite/functions/sqlite-last-insert-rowid.xml b/reference/sqlite/functions/sqlite-last-insert-rowid.xml index d915052d01..e08c94cd80 100644 --- a/reference/sqlite/functions/sqlite-last-insert-rowid.xml +++ b/reference/sqlite/functions/sqlite-last-insert-rowid.xml @@ -1,5 +1,5 @@ - + sqlite_last_insert_rowid @@ -9,11 +9,11 @@ Description intsqlite_last_insert_rowid - resourcedb + resourcedbhandle Returns the rowid of the row that was most recently inserted into the - database db, if it was created as an + database dbhandle, if it was created as an auto-increment field. diff --git a/reference/sqlite/functions/sqlite-open.xml b/reference/sqlite/functions/sqlite-open.xml index 6363221181..80eb5b6650 100644 --- a/reference/sqlite/functions/sqlite-open.xml +++ b/reference/sqlite/functions/sqlite-open.xml @@ -1,5 +1,5 @@ - + sqlite_open @@ -14,7 +14,7 @@ string&error_message - Returns a resource on success, &false; on error. + Returns a resource (database handle) on success, &false; on error. The filename parameter is the name of the diff --git a/reference/sqlite/functions/sqlite-query.xml b/reference/sqlite/functions/sqlite-query.xml index c092e82952..4e58eb7e85 100644 --- a/reference/sqlite/functions/sqlite-query.xml +++ b/reference/sqlite/functions/sqlite-query.xml @@ -1,5 +1,5 @@ - + sqlite_query @@ -11,17 +11,18 @@ Description resourcesqlite_query - resourcedb + resourcedbhandle stringquery resourcesqlite_query stringquery - resourcedb + resourcedbhandle Executes an SQL statement given by the query against - a given database (specified by the db parameter). + a given database handle (specified by the dbhandle + parameter). For queries that return rows, this function will return a result handle diff --git a/reference/sqlite/functions/sqlite-unbuffered-query.xml b/reference/sqlite/functions/sqlite-unbuffered-query.xml index 620256e2da..06808bcd94 100644 --- a/reference/sqlite/functions/sqlite-unbuffered-query.xml +++ b/reference/sqlite/functions/sqlite-unbuffered-query.xml @@ -1,5 +1,5 @@ - + sqlite_unbuffered_query @@ -9,13 +9,13 @@ Description resourcesqlite_unbuffered_query - resourcedb + resourcedbhandle stringquery resourcesqlite_unbuffered_query stringquery - resourcedb + resourcedbhandle sqlite_unbuffered_query is identical to