Something like dibi::fetchSingle() in nette database?

Notice: This thread is very old.
Ja
Member | 259
+
0
-

Is there something like dibi::fetchSingle() in nette database?

I've got some struggle with it right now.

What I tried is

<?php
$res= $this->db->table('settings')->fetch();
$something = $res->school_year;
dump($something);
?>

but when I dump it, it returns activeRow

<?php
Nette\Database\Table\ActiveRow #0e64
table private => Nette\Database\Table\Selection #f397 data private => array (1)
id => 4
dataRefreshed private => FALSE isModified private => FALSE
?>

but it should return 1 (or some id of school_year)

(btw, there is only one row in settings table, no primary key)

Last edited by Ja (2014-04-30 17:07)

Oli
Member | 1215
+
0
-

It's weird. I'm pretty sure, it should return just number. What is yours Nette version? I don't know if something changed in 2.2. I use 2.1 and there should return number.

Ja
Member | 259
+
0
-

2.1.2

Ja
Member | 259
+
0
-

Just note – trying it on another table and it works! InnoDB tables.

btw, is there any equivalent to fetchSingle() or I have to access it always through ->var or [‘var’]?

Ja
Member | 259
+
0
-

Last update, property $res->school_year DOES NOT EXIST! It was $res->id_school_year… don't know why tracy didn't shout… :-/

David Grudl
Nette Core | 7444
+
0
-

It is a main feature. It points to referenced table.