I have 2 tables 1 for "Services" and another for "Inbounds" that Inbonuds table has a foreign key to the Services table. Now I want to show inbounds rows in a <table> in my view. Everything seems OK but there is a not reliable condition with Builder. Let me explain:
$builder = $this->modelsManager->createBuilder()
->columns('*')
->from('App\Model\Inbounds')
->join('App\Model\Services')
->orderBy('App\Model\Inbounds.id DESC')
->where("1=1");
the output of $builder->getQuery()->getSingleResult()
is a Phalcon\Mvc\Model\Row object that contains 2 properties like below:
object(Phalcon\Mvc\Model\Row)[159]
public 'autocharge' => <-----PROBLEM IS HERE ******************
object(App\Model\Inbounds)[160]
public 'id' => string '12' (length=2)
public 'msisdn' => string '09121234567' (length=11)
public 'fk_services_id' => string '1' (length=1)
public 'created_at' => string '2014-11-29 15:17:00' (length=19)
public 'autocharge' => string '0' (length=1)
//
// blah blah blah ...
//
public 'slogan' => <-----PROBLEM IS HERE **********************
object(App\Model\Services)[161]
public 'id' => string '1' (length=1)
public 'mci_service_id' => string '677' (length=3)
public 'name' => string '...' (length=38)
public 'status' => string '1' (length=1)
public 'slogan' => string '...' (length=76)
//
// blah blah blah ...
///
As you can see in the output's dump, The builder has used the last table's field name (autocharge, slogan) as assign property and this is completely unreliable. I unified the last field's name is both tables and it caused overwriting the assign property.
I'm sure this is a bug and I'll report it inn Github but I want to hear your ideas to. Github issue link