0

I try to follow this tutorial on GitHub (https://github.com/lowtower/zend-expressive2-tutorial)

I understand everything (I think) but I wonder, what happens if I need to relate different tables using the TableGateway interface?

Taking the aforementioned tutorial as a guide, if my album is related to other tables in my database, how do I implement it in AlbumTableGateway? example, if I have another table called categories ...

or simply I must dispense with using the TableGateway interface, and if so, how can I implement this new solution in this guide?

1 Answers1

0

Select, Update, Delete and Insert classes of zf-db accepts table name as parameter. You Don't have to use same table you mentioned in construct method of TableGateway. Also You have Join as Sql abstraction. Have a look to documentation it's not that hard. I'm sure you can handle this but here's a little example.

$this->getSql()->select('table1')
               ->columns(['clmn_1','clmn_2'])
               ->join('table2', 'table2.clmn_1 = table1.clmn_2', [])
               ->where(new Operator('table1.clmn_1', Operator::OP_EQ, 3));