i am using this PHP code for getting rows but it’s getting error
$db = new PDO('sqlite:db/logs');
$result = $db->exec("SELECT * FROM users");
while($row = $result->fetch(SQLITE_ASSOC))
{
}
I am using sqlite3 and php5 and i want to know that
-
am i connecting with right code to the database i’ve also used
sqlite.open()but it’s also getting error? -
This
new PDO('sqlite:db/logs')connect with database but why new is it create new db everytime -
my main problem is i am getting error where while loop is that
Call to a member function fetch() on a non-object
please help me out this i am newbie in php and sqlite
You can not use
whileusing PDO, you can use it using procedural approach.Some reference: REFERENCE LINK
You can use
$db->execforinsert&updatequery. Not when you want to fetch the records.Try the following changes.