E
E
empr2016-05-24 23:13:04
PHP
empr, 2016-05-24 23:13:04

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();                                      // обновит автору имя
 }

Is there something similar? I tried Redbeanphp, but everything is a little more complicated there, and simplicity is in priority.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sanes, 2016-05-24
@Sanes

Вот вроде простая, посмотрите.

Александр Аксентьев, 2016-05-25
@Sanasol Куратор тега PHP

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

R
Rikcon, 2016-05-24
@Rikcon

propelorm.org ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question