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
0
votes
0 answers

ZF 1.12 and NULL constraint

I use ZF 1.12 and gateway models. My problem is getting data with models, because some foreign keys may NULL, so when I ask for findDependentRowset() I got exception: Invalid parameter number: no parameters were bound, query was: SELECT…
hurvajs
  • 1
  • 2
0
votes
1 answer

Zendframework 2 postgresql update with "not"

Is is possible to pass to database the following sql query using tableGateway, if so, how would such a command look like ? UPDATE table_data SET active = not active where table_data.id = 12;
Marko Čepo
  • 185
  • 13
0
votes
2 answers

Zend 2 join with select

I have to make a join with a select in Zend 2,is there a way to do it?I saw that join expect first paremetr to be a string( name of the table you join). I manage to did a select with another select using something like this $this->select(function…
WebDeveloper
  • 201
  • 1
  • 2
  • 5
0
votes
1 answer

Zend framework 2 model for database, separate model for each table?

I looked through the manual of Zend Framework 2 about creating model to managing operations on table. Is the class with method exchangeArray() is necessary? It's only copy data :/ Can i create one model to manage a few tables? I created two…
0
votes
1 answer

Zend Framework 2 model foreign keys

I am now approaching Zend Framework 2 and I followed the tutorial on creating a simple CRUD application. Everything is fine but now I want to, for instance, add a genre to the album. I added a category table to the database and created a foreign key…
0
votes
1 answer

Change property of an object in a foreach loop php

I have an array of objects $comments. I get it through calling TableGateway wise call to database. $comments = $this->getCommentsTable()->getComments($theme_id); I now need to change one of the properties of array object elements: foreach…
user3667171
0
votes
3 answers

How to get id of inserted record in zend framework

I want to get id of inserted record in zf2. I found solution using scope_identity in php. But how to use it in zend? My code in indexcontroller is
rack_nilesh
  • 553
  • 5
  • 18
0
votes
2 answers

How to combine lower and like in ZF2?

How to get SQL like this : select * from foo where LOWER(foo_name) like '%test%'; I know that I can achieve this: select * from foo where LOWER(foo_name) = 'test'; By: $where->addPredicate(new Predicate\Expression('LOWER(foo_name) = ?', 'test'…
GingerHead
  • 8,130
  • 15
  • 59
  • 93
0
votes
1 answer

ZF2 Tablegateway: Update dataset with self refering data

I´m struggling with a quite simple SQL statement in ZF2 tablegateway. The SQL Statement should finally be: UPDATE tbl SET sortOrder=sortOrder+1 WHERE parentId='1' As you can see I simply want to incremt all sortOrder values by one for all datasets…
Michael
  • 2,966
  • 3
  • 30
  • 33
0
votes
2 answers

Zend Framework 2: TableGateway

I am using the TableGateway from Zend Framework 2. My problem is that I cannot get the between function to work. This is my code that I have for now, the output is just nothing: public function fetchBetween($startDate, $endDate) { $where = new…
kevingoos
  • 3,785
  • 4
  • 36
  • 63
0
votes
2 answers

Fields getting NULL after editing

I have developed Zend 2 application. There is form to edit existing data. Some fields in table is not included in the form. Thus, when editing those records, fields not in form are saved as NULL. How to fix it ? Model - namespace…
ChamingaD
  • 2,908
  • 8
  • 35
  • 58
0
votes
2 answers

Alternative to TableGateway for Zend Framework 2

I'm using Zend framework 2 to create web pages. Through TableGateway I'm accessing my PostgreSQL DB. Is there any alternative to TableGateway that can be used effectively in Zend framework 2, with easy-to-use documentation and stuff? I'm trying to…
GingerHead
  • 8,130
  • 15
  • 59
  • 93
0
votes
1 answer

Using TableGateway and a Class Factory to create a ResultSet of different Classes - ZF2

I have a question table in MySQL, a question TableGateway and a QuestionFactory Model. Based on the QuestionType received by the TableGateway I would like to instantiate a different class e.g. TextQuestion(), BoolQuestion() etc. In a fetchall…
Aborgrove
  • 288
  • 5
  • 16
0
votes
0 answers

ZF2 - Is it possible in any way to add data to the Rowset after pagination?

I have in module.php something like that 'OrderTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Order()); return new…
Tomek Kobyliński
  • 1,290
  • 14
  • 25
0
votes
1 answer

(Why) Is Zend\Db\ResultSet a TableGateway Feature?

The Zend Framework 2 documentation for the Zend\Db\TableGateway\TableGateway says, that: The [Zend\Db\TableGateway\TableGateway] constructor can take Features in 3 different forms: as a single feature object, as a FeatureSet object, or as an array…
automatix
  • 14,018
  • 26
  • 105
  • 230