cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Models relationship

Open ddenysov opened this issue 13 years ago • 4 comments

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;

ddenysov avatar Jan 03 '13 09:01 ddenysov

This is currently under development and will be released in 0.9.0

niden avatar Jan 14 '13 20:01 niden

Thanx! Could you also implement hasMany relation?

$product = new Product();
$product->category[] = $category;
$product->category[] = $anotherCategory;
$product->category[] = $anotherCategory2;
$product->save();

ddenysov avatar Jan 15 '13 15:01 ddenysov

Hey Denis, saving has-many relations is already implemented in 0.9.0 (https://gist.github.com/4532426)

ghost avatar Jan 15 '13 18:01 ghost

Awesome. Thanx, I'll try it.

ddenysov avatar Jan 15 '13 21:01 ddenysov