I'm using Sqlite on my website. I just want to get birth date of a user from database.
Here is the script I tried but didn't work.
$data = $db->rawQuery('SELECT * FROM userdatabse WHERE title='.$username);
echo $data->date;
I'm using Sqlite on my website. I just want to get birth date of a user from database.
Here is the script I tried but didn't work.
$data = $db->rawQuery('SELECT * FROM userdatabse WHERE title='.$username);
echo $data->date;
In SQLite, querySingle() executes a query and returns a single result.
Try
$result = $db->querySingle('SELECT date_of_birth FROM userdatabse WHERE title='.$username', true);
var_dump($result);
echo $result;
NOTE :
Since we queried for just one column(date of birth), therefore it will return a string with the date of birth.
Had we queried for many columns say date_of_birth and mobile_number, it would have returned an array with these fields.
Example :
$result = $db->querySingle('SELECT date_of_birth, mobile_number FROM userdatabse WHERE title='.$username', true);
print_r($result);
The above query will return something like :
Array
(
[date_of_birth] => 1993-05-05
[mobile_number] => 9999999999
)
where as the query :
$result = $db->querySingle('SELECT date_of_birth FROM userdatabse WHERE title='.$username', true);
echo $result;
will return something like this :
1993-05-05