php访问sqlite数据库的例子
Libérer: 2016-07-25 08:57:43
original
1635 Les gens l'ont consulté
-
-
$dbconn = sqlite_open('phpdb');
if ($dbconn) {
- sqlite_query($dbconn, "CREATE TABLE animal(Name VARCHAR(255), MaxAge INT);");
- sqlite_query($dbconn, "INSERT INTO animal VALUES ('A', 15)");
- $result = sqlite_query($dbconn, "SELECT Name FROM animal");
- var_dump(sqlite_fetch_array($result, SQLITE_ASSOC));
- } else {
- print "Connection to database failed!\n";
- }
-
复制代码
例2,将结果集保存到数组中
-
-
$rows = array();
while($row = sqlite_fetch_array($result, $res_type, $decode)) {
- $rows[] = $row;
- }
- ?>
-
-
复制代码
附,SQLite Error Constants
SQLITE_OK No error occurred.
SQLITE_ERROR SQLite error (or database not found).
SQLITE_INTERNAL An internal SQLite error.
SQLITE_PERM Access permission denied.
SQLITE_ABORT Callback routine aborted.
SQLITE_BUSY The database file is currently locked.
SQLITE_LOCKED A table within the database is locked.
SQLITE_NOMEM SQLite memory allocation error.
SQLITE_READONLY An attempt to write to a read-only database.
SQLITE_INTERRUPT Interrupted operation.
SQLITE_IOERR A file I/O error has occurred.
SQLITE_CORRUPT The specified database is corrupted.
SQLITE_FULL Database is full.
SQLITE_CANTOPEN Could not open database file.
SQLITE_PROTOCOL Database lock protocol error.
SQLITE_SCHEMA The database schema changed.
SQLITE_TOOBIG Too much data for a single row.
SQLITE_CONSTRAINT Abort due to constraint violation.
SQLITE_MISMATCH Data type mismatch.
SQLITE_AUTH Authorization denied.
SQLITE_ROW sqlite_step() has another row ready.
SQLITE_DONE sqlite_step() has finished executing. |
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers articles par auteur
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31