File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,8 @@ public function fetchAll()
265265 */
266266 public function fetchAssoc ($ path )
267267 {
268- return Nette \Utils \Arrays::associate ($ this ->fetchAll (), $ path );
268+ $ rows = array_map ('iterator_to_array ' , $ this ->fetchAll ());
269+ return Nette \Utils \Arrays::associate ($ rows , $ path );
269270 }
270271
271272
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Test: Nette\Database\Table: Fetch assoc.
5+ *
6+ * @dataProvider? ../databases.ini
7+ */
8+
9+ use Tester \Assert ;
10+
11+ require __DIR__ . '/../connect.inc.php ' ; // create $connection
12+
13+ Nette \Database \Helpers::loadFromFile ($ connection , __DIR__ . "/../files/ {$ driverName }-nette_test1.sql " );
14+
15+
16+ test (function () use ($ context ) {
17+ $ apps = $ context ->table ('book ' )->order ('title ' )->fetchAssoc ('id=title ' ); // SELECT * FROM `book` ORDER BY `title`
18+ Assert::same (array (
19+ 1 => '1001 tipu a triku pro PHP ' ,
20+ 4 => 'Dibi ' ,
21+ 2 => 'JUSH ' ,
22+ 3 => 'Nette ' ,
23+ ), $ apps );
24+ });
You can’t perform that action at this time.
0 commit comments