D
D
Deprimovec2017-03-19 22:53:34
PHP
Deprimovec, 2017-03-19 22:53:34

Is it possible to use queries in Phalcon ORM like in Eloquent?

Hello. The question is generally simple.
Is it possible to use queries like Eloquent in Phalcon ORM like:

$category = Category::findFirst($id);
$tags = $category->articles()->tags;

The project is going to Phalcon, but this flexibility from Eloquent is very much lacking. I went through all the documentation, but either I didn’t wool well, or it’s not there.
Let me explain: the models are created, the connections are set (I'm not such a bad wooler :).
You need to get all the Tags (tag) from Articles (article) in the Category (category) with the specified $id.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SimBioT19, 2017-03-20
@SimBioT19

I guess you mean

$product = Products::findFirst($id);

$tags = $product->tags;
//или
$tags = $product->getTags();
// можно
$tags = $product->getTags('id != 1');
// и даже так 
 $tags = $this->modelsManager->executeQuery(
                "SELECT t.* FROM \Models\Products p 
                 LEFT JOIN \Models\Tags t ON t.postId = p.id ");

But before that, you need to establish relationships in models, where alias is set - tags
PS. Wool very badly
https://docs.phalconphp.com/en/3.0.2/reference/mod...
https://docs.phalconphp.com/en/latest/reference/models

A
Alexander Aksentiev, 2017-03-19
@Sanasol

I have never seen or used a falcon, but maybe there is an answer in the docks? https://docs.phalconphp.com/en/3.0.0/reference/mod...

E
Evgeny Borisov, 2019-03-01
@Agel_Nash

Is it possible to use queries in Phalcon ORM like in Eloquent?

https://github.com/josuegrullon/phalcon-eloquent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question