Created
October 9, 2021 18:11
-
-
Save harshityadav95/e470487c130f3c4ffafcca77d3a5a591 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 | |
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