Skip to content

Instantly share code, notes, and snippets.

@hrach
Created March 21, 2013 22:09
Show Gist options
  • Save hrach/5217252 to your computer and use it in GitHub Desktop.
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 …
<?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
@Elijen
Copy link

Elijen commented Mar 27, 2013

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