one-to-many model validation

26 views
Skip to first unread message

Alberto Ruffo

unread,
May 15, 2013, 8:58:14 AM5/15/13
to redbe...@googlegroups.com
Hello, if i consider this tables:

Customer
-----------------------------
id, name, surname

AND

Address
-----------------------------
id, address, number, city, customer_id


Customer has more addresses, so:

$address = R::dispense...
$address->import(...); // for instance, from $_POST['address']

$customer = R::dispense...
$customer->import(...); // for instance, from $_POST['customer']

$customer->ownAddress[] = $address;

try {
R::store($customer);
} catch (ModelException $e) {}

In this case, how do model validations work? 
I have to throw exception once and retrieve errors of both at the same time; but there are two model-validations which need two exceptions.
Reply all
Reply to author
Forward
0 new messages