Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Created October 9, 2021 18:12
Show Gist options
  • Save harshityadav95/6c7daef32d23158c9173845859dc8661 to your computer and use it in GitHub Desktop.
Save harshityadav95/6c7daef32d23158c9173845859dc8661 to your computer and use it in GitHub Desktop.
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('test.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql =<<<EOF
CREATE TABLE COMPANY
(ID NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY TEXT);
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
echo "Table created successfully\n";
}
$db->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment