<?php
/* @var $connection Doctrine\DBAL\Connection */
// Regular usage with fetchAll()
$sql = 'SELECT * FROM test WHERE id < ?';
$result = $connection->executeQuery($sql, [4])
->fetchAll();
dump($result);
// Using project() to give result a format
$function = function ($row) {
return $row['id'].';'.$row['name'].';'.
$row['creation_date'];
};
$result = $connection->project($sql, [4], $function);
dump($result);
^ array:3 [
0 => array:3 [
"id" => 1
"name" => "foo"
"creation_date" => "2014-07-20 11:37:29"
]
1 => array:3 [
"id" => 2
"name" => "test"
"creation_date" => "2014-07-20 10:40:22"
]
2 => array:3 [
"id" => 3
"name" => "bar"
"creation_date" => "2014-07-23 07:27:18"
]
]
^ array:3 [
0 => "1;foo;2014-07-20 11:37:29"
1 => "2;test;2014-07-20 10:40:22"
2 => "3;bar;2014-07-23 07:27:18"
]