looking for examples to learn more

mes
Member | 8
+
0
-

Hi,

I do have obviously massive trouble to understand how to use and what's the result of fetch(), fetchPairs() and fetchAssoc(). For now I invested some hours. But I have to admit I've got stucked.

Are there any examples where I can understand the over all structure?

The single lines on https://doc.nette.org/…ase/explorer#… are to short for me.
I'm looking for some kind of snippet to understand how to reach a single value or select data of a single row.

Usually I use var_dump() to learn more. But Tracy's dump() is not working for me: I do receive a
“Cannot send header after HTTP headers have been sent”

Any advises how to carry on?

Rick Strafy
Nette Blogger | 78
+
+1
-

Hi, I cannot help you with nette database, since I'm using Doctrine ORM (if you want to see some Nette-Doctrine example check out https://github.com/…work/Website, it's integrated via this integration https://contributte.org/nettrine/).

Btw use bdump() (short for bar dump) in php, it will dump the variables to latte panel, same as {dump} in latte.

mes
Member | 8
+
0
-

@RickStrafy Thank you so much!

bdump() brings me a huge step forward – I did know this command.

Also your link was helpful, just 3 minutes later I understood
A query results in an ActiveRow $result
a field can accessed by $result->field

        $result = $this->database->query('SELECT * FROM minecraft_server');

        foreach ($result as $row) {
            $server = new Server();
            $server->id = $row->id;
            $server->name = $row->name;
			...