Reputation: 2155
Using CakePHP 2.5 rawQuery
, which is the best way to iterate through the results?
I am using native PHP oci_execute
then oci_fetch_array
.
Is there any CakePHP way that can do the same?
$results = $db->rawQuery($data_sql);
$search_results = oci_execute($results);
while ( ( $row = oci_fetch_array($search_results, OCI_BOTH ) ) != false)
{
Upvotes: 0
Views: 320
Reputation: 4469
Method DboSource::rawQuery()
returns a PDOStatement
object if the query was successful.
You can use the standard methods provided by PHP to deal with PDOStatement
objects.
This should work:
$results = $db->rawQuery($data_sql);
foreach ($results as $row){
//code inside loop
}
For further information, see:
Upvotes: 1