note 92771 added to function.sqlite-fetch-single
| From: | (Vantuz) | Date: | Sat, 08 Aug 2009 11:26:14 +0000 |
| Subject: | note 92771 added to function.sqlite-fetch-single | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159210@lists.php.net to get a copy of this message | ||
With the help of sqlite_fetch_single, you can quickly and easily calculate the number of elements in
the table
<?php
// create new database (OO interface)
$db = new SQLiteDatabase('database.db', 0666);
// create table inbox and paste data
$db->queryExec("
CREATE TABLE inbox (
inbox_id INTEGER NOT NULL PRIMARY KEY,
inbox_send varchar(20) NOT NULL,
inbox_text TEXT NOT NULL,
inbox_time INTEGER UNSIGNED NOT NULL,
inbox_user varchar(20) NOT NULL
);");
$ins_query = "
INSERT INTO inbox (inbox_send, inbox_text, inbox_time, inbox_user) VALUES ('Ilia1',
'Message1', '".time()."', 'my_name');
INSERT INTO inbox (inbox_send, inbox_text, inbox_time, inbox_user) VALUES ('Ilia2',
'Message2', '".time()."', 'user');
INSERT INTO inbox (inbox_send, inbox_text, inbox_time, inbox_user) VALUES ('Ilia2',
'Message3', '".time()."', 'my_name');
";
$db->queryExec($ins_query);
//view all posts by my_name
$total = $db->singleQuery("SELECT count(*) FROM inbox WHERE
inbox_user='my_name';");
echo $total;
// the result will be the number 2
/* P.S. sorry for my english */
?>
----
Server IP: 195.54.192.44
Probable Submitter: 188.128.45.131
----
Manual Page -- http://www.php.net/manual/en/function.sqlite-fetch-single.php
Edit -- https://master.php.net/note/edit/92771
Del: integrated -- https://master.php.net/note/delete/92771/integrated
Del: useless -- https://master.php.net/note/delete/92771/useless
Del: bad code -- https://master.php.net/note/delete/92771/bad+code
Del: spam -- https://master.php.net/note/delete/92771/spam
Del: non-english -- https://master.php.net/note/delete/92771/non-english
Del: in docs -- https://master.php.net/note/delete/92771/in+docs
Del: other reasons-- https://master.php.net/note/delete/92771
Reject -- https://master.php.net/note/reject/92771
Search -- https://master.php.net/manage/user-notes.php