Skip to content

Commit

Permalink
Bug fix for limit sql
Browse files Browse the repository at this point in the history
  • Loading branch information
fordnox committed Jun 7, 2014
1 parent 8f1d269 commit 1a06529
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Mikron.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function findAll($type, $sql = null, $values = array())
{
$table = $this->getTableName($type);
$class = $this->getClassName($type);
$sql = "SELECT * FROM $table WHERE $sql LIMIT 1";
$sql = "SELECT * FROM $table WHERE $sql";
$stmt = $this->pdo->prepare($sql);
$stmt->setFetchMode( \PDO::FETCH_CLASS, $class );
$stmt->execute($values);
Expand Down
10 changes: 10 additions & 0 deletions MikronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ public function testFindOne()

public function testFindAll()
{
$newEntity = new Entity();
$newEntity->name = 'Name 1';
$this->mikron->store($newEntity);

$newEntity = new Entity();
$newEntity->name = 'Name 2';
$this->mikron->store($newEntity);

$entities = $this->mikron->findAll("entity", "1");
$this->assertEquals(2, count($entities));
foreach($entities as $entity) {
$this->assertInstanceOf('Entity', $entity);
}
Expand Down Expand Up @@ -128,6 +137,7 @@ public function testGetAll()
$this->mikron->store($newEntity);

$list = $this->mikron->getAll("SELECT * FROM entity WHERE 1");
$this->assertEquals(2, count($list));
foreach($list as $item) {
$this->assertInternalType('array', $item);
$this->assertEquals('Name', $item['name']);
Expand Down

0 comments on commit 1a06529

Please sign in to comment.