Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Created October 9, 2021 18:11
Show Gist options
  • Save harshityadav95/e470487c130f3c4ffafcca77d3a5a591 to your computer and use it in GitHub Desktop.
Save harshityadav95/e470487c130f3c4ffafcca77d3a5a591 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
SELECT * from COMPANY;
EOF;
$ret = $db->query($sql);
while($row = $ret->fetchArray(SQLITE3_ASSOC) ){
echo "ID = ". $row['ID'] . "\n";
echo "<br>";
// add the BR tag to print the values in a new line
echo "NAME = ". $row['NAME'] ."\n";
echo "ADDRESS = ". $row['ADDRESS'] ."\n";
echo "SALARY = ".$row['SALARY'] ."\n\n";
}
echo "Operation done successfully\n";
$db->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment