jecarfor
jecarfor

Reputation: 529

Zend DB fetchAll() not working with "id" column with values over 926

I've been trying to retrieve some data using Zend DB fetchAll(), but the problem I'm facing is that I have a table that has around 475 rows, with an incremental ID starting at 755 and ending in 1230, but when I try to get data using

$select = $db->select()->from('projects');
$stmt = $db->query($select);
$result = $stmt->fetchAll();

entries whose IDs are over 926 are not retrieved, I've though it was a memory issue so I tried to limit my query for only those above 926

$select = $db->select()->from('projects')->where('id>926');
$stmt = $db->query($select);
$result = $stmt->fetchAll();

But I got nothing, I even tried with just 1 id.

$select = $db->select()->from('projects')->where('id=927');
$stmt = $db->query($select);
$result = $stmt->fetchAll();

But nothing happened.

Upvotes: 0

Views: 517

Answers (1)

liyakat
liyakat

Reputation: 11853

you can use like below

$select = $db->select()->from('projects')->where('id = ?', 926);
$stmt = $db->query($select);
$result = $stmt->fetchAll();

or

$select = $db->select()->from('projects')->where('id > ?', 926 );
$stmt = $db->query($select);
$result = $stmt->fetchAll();

It will also prevent SQL injection in your query.

Upvotes: 1

Related Questions