cphalcon
cphalcon copied to clipboard
[NFR] Models relationship
Is it possible to save models ralations like in Doctrine ? Fox example:
$category = new Category();
$category->name = 'Main Products';
$category->save();
$product = new Product();
$product->name = 'Foo';
$product->price = 19.95;
$product->category = $category;
$product->save();
And work with products and categories in this way:
$product = Product::findFirst(1);
echo $product->category->name;
This is currently under development and will be released in 0.9.0
Thanx! Could you also implement hasMany relation?
$product = new Product();
$product->category[] = $category;
$product->category[] = $anotherCategory;
$product->category[] = $anotherCategory2;
$product->save();
Hey Denis, saving has-many relations is already implemented in 0.9.0 (https://gist.github.com/4532426)
Awesome. Thanx, I'll try it.