mikecao / sparrow

A simple database toolkit for PHP
MIT License
289 stars 68 forks source link

Join fix name conflict #26

Closed kamov closed 7 years ago

kamov commented 7 years ago

I have a join with 2 table that have the same field name. But how to distinct the field names?

Usually I do like below:

"SELECT posts. , categories. FROM ...."

Now query is just "SELECT * FROM ...."

Thanks!

kamov commented 7 years ago

NOTE: If I do this:

->select(['posts.* ', 'categories.* ']);

the fields with the same name is always merged

kamov commented 7 years ago

This is my query:


$db->from('posts')
            ->leftJoin('categories', ['posts.category_id' => 'categories.id', 'categories.id' => 2])
            ->where('posts.status', 1)
            ->where('categories.status', 1)
            ->select(['pages.*', 'categories.*'])
            ->sql();
kamov commented 7 years ago

If I run the query in phpmyadmin, then work fine, all fields are show. But with sparrow the same field name are merged.

kamov commented 7 years ago

fixed