jeudi 11 juin 2015

Returning an int from a single row in a Sqlite DB

I need to return 2 ints that are from a DB, but, I can't seem to get the query right.

$result1 = $db->query('SELECT * FROM StoredData WHERE VoteName="foo"')->fetch(); 
$result2 = $db->query('SELECT * FROM StoredData WHERE VoteName="bar"')->fetch();

I need result 1/2 to return ints from the column named "VoteTotal", I have tried various things without much luck, including changing the * to just VoteTotal which I thought would do it.

The VoteName is unique, I've also tried fetchcolumn without any luck :(

Schema is simply:

ID, VoteName, VoteTotal

Aucun commentaire:

Enregistrer un commentaire