Created
October 9, 2021 18:12
-
-
Save harshityadav95/6c7daef32d23158c9173845859dc8661 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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