Mij lijkt het toch handiger werken als je $connectie->Uitvoeren() gebruikt dan $ding->dang()->doe()->dit()->uitvoeren(); 


Nielsie schreef:Het is nog steeds Active Record, niet één of andere rare db classMij lijkt het toch handiger werken als je $connectie->Uitvoeren() gebruikt dan $ding->dang()->doe()->dit()->uitvoeren();
Raaoul schreef:Dan moet je met relations gaan werkenJOINS moet je obviously nooit doen met query builders als dit doen. Ingewikkelde querys kun je ook gewoon zelf maken met ->sql(). Mocht je dan gebruik willen maken van iets mooiere functies als ->find(), ->create(), ... kan dat nog altijd. Niemand verplicht je tot iets.
Wil je gewoon iets simpel ophalen, dan hoef je zelf niet altijd SQL te schrijven. Het is altijd wel netter om een wrapper rond zulke dingen te schrijven.
Daarom dat er ook iets bestaat als ActiveRecord en daarom ook dat AR geïmplementeerd zit in vele populaire frameworks.
Dan heb je ingebouwde Joins. Of eigenlijk gebruik je dan helemaal geen Joins. Hij doet 2 queries, maar het maakt hem wel een stuk flexibeler 
Rik schreef:Omdat user een table is, en geen user op zich. Hierover gaat dit topic niet!!!Maar waarom zou je dan niet gewoon
$user->addMoney(10);
Doen in plaats van
$user->find(...)->update(money, +10);
[COLOR= #0000BB]<?php
$dbTable[/COLOR] [COLOR= #007700]= new[/COLOR] User[COLOR= #007700]([/COLOR]Database[COLOR= #007700]::[/COLOR]getDatabaseWithDefaultAdapter[COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$dbTable[/COLOR][COLOR= #007700]->[/COLOR]select[COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$select[/COLOR][COLOR= #007700]->[/COLOR]where[COLOR= #007700]([/COLOR][COLOR= #DD0000]username = ?[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Raoul[/COLOR][COLOR= #007700]))->[/COLOR]order[COLOR= #007700]([/COLOR][COLOR= #DD0000]id DESC[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$select[/COLOR][COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700]->[/COLOR]username[COLOR= #007700];[/COLOR]
?> [COLOR= #0000BB]<?php
$dbTable[/COLOR] [COLOR= #007700]= new[/COLOR] User[COLOR= #007700]([/COLOR]Database[COLOR= #007700]::[/COLOR]getDatabaseWithDefaultAdapter[COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$dbTable[/COLOR][COLOR= #007700]->[/COLOR]find[COLOR= #007700]([/COLOR][COLOR= #0000BB]21[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$user[/COLOR][COLOR= #007700]->[/COLOR]username [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Jan[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// nu:[/COLOR]
[COLOR= #0000BB]$user[/COLOR][COLOR= #007700]->[/COLOR]save[COLOR= #007700]();[/COLOR]
[COLOR= #FF8000]// vroeger:[/COLOR]
[COLOR= #0000BB]$dbTable[/COLOR][COLOR= #007700]->[/COLOR]save[COLOR= #007700]([/COLOR][COLOR= #0000BB]$user[/COLOR][COLOR= #007700]);[/COLOR]
?> [COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbTable[/COLOR][COLOR= #007700]->[/COLOR]all[COLOR= #007700]() as[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700]->[/COLOR]username[COLOR= #007700];
}[/COLOR]
?>
Ik ben in ieder geval wel nieuwsgierig 
Jenner schreef:De classes gebruiken heel wat andere classes waardoor ik het niet zomaar als een los script online kan zetten. Nog eventjes geduld.Kun je eens het script online zetten?Ik ben in ieder geval wel nieuwsgierig
