add SQLite3 PHP example

This commit is contained in:
Alexander Popov 2022-03-28 21:05:30 +03:00
parent 75e3463ec7
commit b0dc89a18e
Signed by: iiiypuk
GPG Key ID: 3F76816AEE08F908
4 changed files with 30 additions and 0 deletions

View File

@ -6,6 +6,10 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.php]
indent_style = space
indent_size = 4
[{*.html,*.css}]
indent_style = tab
indent_size = 4

1
PHP/Fenom.md Normal file
View File

@ -0,0 +1 @@
# Fenom

View File

@ -2,3 +2,7 @@
## std
- [`gettype`](gettype.php) - Get the type of a variable
- [`SQLite3`](sqlite3.php) - Простой использования класса SQLite3
## Libs
- [`Fenom`](Fenom.md) - fenom

21
PHP/sqlite3.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/**
* Простой пример расширения класса SQLite3 и изменения параметров конструктора.
* После чего использование метода open для инициализации БД.
*/
class MyDB extends SQLite3
{
function __construct()
{
$this->open('mysqlitedb.db');
}
}
$db = new MyDB();
$db->exec('CREATE TABLE foo (bar STRING)');
$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')");
$result = $db->query('SELECT bar FROM foo');
var_dump($result->fetchArray());
?>