Created
March 21, 2013 22:09
-
-
Save hrach/5217252 to your computer and use it in GitHub Desktop.
Premyslim nad novym api pro Nette\Database.
- je treba osekat aktualni selection, ktera ma metody delete, insert, atp.
- je treba osekat metody save, update, delete na active row V nize draft api je toto odstraneno. Je zavedena repository. Programator by samozrejme mohl definovat vlastni repository.
Co rikate na navrhovany smer? Jinak, aby bylo …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = $connection->repository('user')->get(1); | |
// $user instanceof Row | |
$users = $connection->repository('user')->query()->where('id in ?', [1, 2, 3]); | |
// $users instanceof SqlBuilder | |
$users = $connection->repository('user')->query()->where('id in ?', [1, 2, 3])->getSelection(); | |
// $users instanceof Selection | |
$connection->repository('user')->delete($user); | |
$connection->repository('user')->delete( | |
$connection->repository('user')->query()->where('id in ?', [1, 2, 3]) | |
// or | |
new SqlBuilder($connection, 'user')->where('id in ?', [1, 2, 3]) | |
); | |
$connection->repository('user')->insert($user); | |
$connection->repository('user')->getSelection(); // fetch all |
DAO je spíše ORM-related, TableGateway ma k NDB blíž.
co je obsahem $user
?
Row nebo ActiveRow, rekneme ze spise standardizovany kontejner, ale ne tak uplne entita.
A mě se to nelíbí! :)
Chápu, že stávající implementace NDB je trochu prasárna a nové API by umožnilo čistější návrh, ale síla NDB je především v jeho jednoduchosti, přímočarosti a magičnosti.
Když budu chtít repositáře nebo vytvořit ORM, použiju Doctrine a nebudu vynalézat kolo s NDB ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mohl bys me odkazat na nejaky autoritativni zdroj, ktery by objasnoval terminy a jejich zodpovednost? Jinak diky za pripominku. Nejde tu ted tolik o nazvoslovi jako spis o vztahy jednotlivych trid :)