1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-17 14:45:06 -05:00

Use fetchAll directly on the connection and bind parameters using ?

This commit is contained in:
Vincent Jousse 2013-12-13 18:44:43 +01:00
parent 56071a0c81
commit 8c2d368cbf
2 changed files with 5 additions and 7 deletions

View File

@ -12,11 +12,9 @@ class EntryRepository
//TODO don't hardcode the user ;) //TODO don't hardcode the user ;)
public function getEntries($userId = 1) { public function getEntries($userId = 1) {
$sql = "SELECT * FROM entries where user_id = :userId"; $sql = "SELECT * FROM entries where user_id = ?";
$stmt = $this->db->prepare($sql); $entries = $this->db->fetchAll($sql, array($userId));
$stmt->bindValue('userId', $userId); return $entries ? $entries : array();
$entries = $stmt->fetchAll();
return $entries;
} }
//TODO don't hardcode the user ;) //TODO don't hardcode the user ;)

View File

@ -19,7 +19,7 @@ class ApiTest extends PocheWebTestCase
) )
); );
$this->assertEquals($client->getResponse()->getContent(), '[]'); $this->assertEquals('[]', $client->getResponse()->getContent());
} }
@ -42,7 +42,7 @@ class ApiTest extends PocheWebTestCase
) )
); );
$this->assertEquals($client->getResponse()->getContent(),'{"id":"1","url":"http:\/\/deboutlesgens.com\/blog\/le-courage-de-vivre-consciemment\/","title":"Le courage de vivre consciemment","content":"Test content","updated":null,"status":null,"bookmark":"0","fetched":"1","user_id":"1"}'); $this->assertEquals('[{"id":"1","url":"http:\/\/deboutlesgens.com\/blog\/le-courage-de-vivre-consciemment\/","title":"Le courage de vivre consciemment","content":"Test content","updated":null,"status":null,"bookmark":"0","fetched":"1","user_id":"1"}]', $client->getResponse()->getContent());
} }