Answer the question
In order to leave comments, you need to log in
Is there an ORM for PHP that can automatically "join" related strings?
Greetings! I am looking for an ORM that can independently determine relationships in the database and works approximately as follows.
There is a MySQL database with the following tables:
posts - publications
authors - authors
cities - cities
countries - countries
Links are configured accordingly.
The posts table has an author field associated with the id field in the authors table.
The authors table has a city field associated with the id field in the cities table.
The cities table has a country field associated with the id field in the countries table.
$posts = $db->posts->where(['author.city.country.name' => 'Russia'])->select();
foreach ($posts as $post)
{
echo $post->author->city->name; // выведет название города автора поста
$post->author->name = mb_strtoupper($post->author->name); //
$post->author->save(); // обновит автору имя
}
Answer the question
In order to leave comments, you need to log in
A very simple ORM.
www.phpactiverecord.org/projects/main/wiki/Associations
And it's better to take Eloquent ORM from Laravel.
https://laravel.com/docs/5.0/eloquent
https://github.com/illuminate/database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question