you connect to the database like this :
try {
$db = new PDO("sqlite:file.sq3");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Error : <br>' . $e->getMessage();
}
PS: You dont need the try and the catch, but we used to get the error and handle it in a nice way as we want to
and next we query like this :
$db->query(SELECT * FROM node WHERE node_name='$nodename'");
and we fetch it like this :
$query = $db->query(SELECT * FROM node WHERE node_name='$nodename'");
$row = $query->fetch(PDO::FETCH_OBJ);
and now you use $row->name
for example
here is more about PDO::FETCH
PDO::FETCH_ASSOC: returns an array indexed by column name as returned in your result set
PDO::FETCH_BOTH (default): returns an array indexed by both column name and 0-indexed column number as returned in your result set
PDO::FETCH_BOUND: returns TRUE and assigns the values of the columns in your result set to the PHP variables to which they were
bound with the PDOStatement::bindColumn() method
PDO::FETCH_CLASS: returns a new instance of the requested class, mapping the columns of the result set to named properties in the
class. If fetch_style includes PDO::FETCH_CLASSTYPE (e.g.
PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE) then the name of the class
is determined from a value of the first column.
PDO::FETCH_INTO: updates an existing instance of the requested class, mapping the columns of the result set to named properties in
the class
PDO::FETCH_LAZY: combines PDO::FETCH_BOTH and PDO::FETCH_OBJ, creating the object variable names as they are accessed
PDO::FETCH_NUM: returns an array indexed by column number as returned in your result set, starting at column 0
PDO::FETCH_OBJ: returns an anonymous object with property names that correspond to the column names returned in your result set