Questions tagged [tablegateway]

The TableGateway is the basic way to access database by zend-framework2

The object is intended to provide an object that represents a table in a database, and the methods of this object mirror the most common operations on a database table.

There are two primary implementations of the that are of the most useful: and . The is an abstract basic implementation that provides functionality for select(), insert(), update(), delete(), as well as an additional API for doing these same kinds of tasks with explicit objects. These methods are selectWith(), insertWith(), updateWith() and deleteWith(). In addition, also implements a “Feature” API, that allows for expanding the behaviors of the base implementation without having to extend the class with this new functionality. The concrete implementation simply adds a sensible constructor to the class so that out-of-the-box, does not need to be extended in order to be consumed and utilized to its fullest.

63 questions
19
votes
7 answers

LEFT JOIN in ZF2 using TableGateway

I have a table: *CREATE TABLE IF NOT EXISTS `blogs_settings` ( `blog_id` int(11) NOT NULL AUTO_INCREMENT, `owner_id` int(11) NOT NULL, `title` varchar(255) NOT NULL, `meta_description` text NOT NULL, `meta_keywords` text NOT NULL, …
5
votes
1 answer

TableGateway with multiple FROM tables

I would like to do a simple INNER JOIN between two tables in Zend2. Concretely, I would like to do this in Zend2: SELECT * FROM foo, bar WHERE foo.foreign_id = bar.id; I have a FooTable: class FooTable { protected $tableGateway; public function…
Sandro Munda
  • 39,921
  • 24
  • 98
  • 123
4
votes
1 answer

When to use tablegateway and Adapter

Zend or I say this whole framework concept is new for me. Some examples are based on tablegateway format, in which you define name of table related to that controller in Module.php. /* 'MYMODULE\Model\CompanyTable' => function($sm) { …
Neelam Gahlyan
  • 366
  • 1
  • 3
  • 12
3
votes
1 answer

Get SQL after Zend\Db\Sql\Select

I'm on zend framework 2. The scenario is, I want to know the actual SQL query after Zend\Db\Sql\Select. I cannot use Zend\Db\Sql\SQL here, and $select = new…
Keyur
  • 1,113
  • 1
  • 23
  • 42
3
votes
0 answers

ZF2 one to many relationship using Database, TableGateways and Form ElementCollection

i'm searching for a strategy to create a one to many raltionship in ZF2, between two tables using TableGateways. Table one is called "workers" and one worker has many "departments". Now i want to have a form for the workers which inlcudes a special…
3
votes
1 answer

Where do Zend\Db\ResultSet\ResultSet objects store the retrieved data?

In a Zend Framework application, that is built pretty similar to the album application from the ZF2 Getting Started tutorial, I use a ResultSet object to transport the data from the model over the controller to the view (for details see the code…
automatix
  • 14,018
  • 26
  • 105
  • 230
3
votes
2 answers

Zend / ZF2 / TableGateway mysql_insert_id replacement?

I am trying to switch from mysql to Zend / TableGateway class. I wonder if there is a method, similar to mysql_insert_id, to get the autoincremented id of the last inserted row. Googling around, I found some answers, pointing to the lastInsertId()…
Gisela
  • 1,194
  • 2
  • 16
  • 30
2
votes
0 answers

ZF2 use multiple TableGatway in Single module

I have one problem. I don't know how to use multiple table and join query in zf2. I'm using service Manager and TableGateway for model. But in this it always use single table. How can I use multiple table in single controller or model? Here I'm…
Amit Kumar Sahu
  • 495
  • 6
  • 15
2
votes
1 answer

Using combine and order together with Table Gateway in ZF2

When adding $select->order(...) to a previously combined Select in Zend Framework 2 the "order by" will only be added to the first Select statement. SELECT `user`.* FROM `user` WHERE `user_id` = :where1 ORDER BY `starttime_dt` ASC ) UNION (…
Gemane
  • 43
  • 8
2
votes
1 answer

what is the difference between doctrine 2 ,Tablegateway and zend_db?

After exploring a lot about zf2 database and model chapter: i did not understand what is most preferable for database part whether to use Tablegateway(As mentioned in the document file) or zend_db or doctrine2(ORM). Like which one more features over…
2
votes
2 answers

Zend Framework 2: How to get ServiceLocator in validation class

I would like to get ServiceLocator in my validation class. I tried get it from Controller instance but it returns null. MyValidation.php namespace Register\Validator; use Zend\Validator\AbstractValidator; use…
user1409508
  • 623
  • 1
  • 12
  • 38
2
votes
1 answer

zf2 The supplied parameters to DbTable failed to produce a valid sql statement, please check table and column names for validity

On authentication I am getting an error message "The supplied parameters to DbTable failed to produce a valid sql statement, please check table and column names for validity." my login controller code is $form= new login(); …
seethal
  • 21
  • 2
2
votes
1 answer

AlbumTableGateway in Zend Framework 2 User Guide

In the chapter "Database and models" of the current (2.1) ZF2 User Guide there a code snippet, I don't understand: (block "Using ServiceManager to configure the table gateway and inject into the AlbumTable") ... class Module { //…
automatix
  • 14,018
  • 26
  • 105
  • 230
2
votes
1 answer

Zend 2 - TableGateway Where Clauses

Hi I am trying to get to grips with Zend 2 and I'm having some problems with where clauses in the table gateway. Below is my table class: //module\Detectos\src\Detectos\Model\OperatingSystemTable.php namespace Detectos\Model; use…
Aydin Hassan
  • 1,465
  • 2
  • 20
  • 41
2
votes
5 answers

Zend Framework 2 Paginator + TableGateway

How to use the database mapper with the paginator? I'm having a bit trouble understanding how I implement the DbSelect paginator using the code below (right now it's using the Iterator adapter which doesn't work for ResultSets). From what I can…
The Pixel Developer
  • 13,282
  • 10
  • 43
  • 60
1
2 3 4 5