O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing queries using TableGateway

After we have seen how to execute simply queries, it is now time to tell you about the TableGateway, and it's incredible functionality. This recipe is all about querying the database through this and showing off its capabilities.

Getting ready

To make full of the following recipe, a Zend Framework 2 skeleton application should be used, with a MySQL server available to connect to. Don't forget that connecting to a MySQL server requires the mysql and mysqli extension enabled in PHP.

How to do it…

What we are going to do first is insert a record in our sample table. After that we will check that it was inserted successfully. Next, we will update the record with some new data, and if that worked we will delete it again ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required