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
1
vote
1 answer

Zend Framework 2 Zend_DB MasterSlaveFeature

The documentation mentions the ability to do master-slave by passing the MasterSlaveFeature to a TableGateway constructor along with the slave adapter as a parameter to the MasterSlaveFeature. My question is how to get access to that slave adapter…
Jeremy Hicks
  • 3,690
  • 5
  • 40
  • 52
1
vote
1 answer

ZF2 tableGateway select

I started with the ZendSkeletonApplication and added a model extending Zend\Db\TableGateway\TableGateway. I have the following method: public function findByType($type) { $rowset = $this->select('type' => $type); return $rowset; } This…
user458753
  • 147
  • 2
  • 3
  • 15
0
votes
1 answer

Zend 2 check if select query returned NULL

I am using select query using Zend 2 like below. I need to check if the above result returned NULL (ie) if the Email column is NULL). $checkEmailId = "Select EmailId from UsersNew where HashedUid='".$newUserId."'"; $Emailquery =…
Sushivam
  • 2,537
  • 4
  • 15
  • 25
0
votes
1 answer

Zend tableGateway Model Delete Query with Multiple IDs

I want to delete multiple rows by TableGateway like below SQL Delete from table where id in (1,2,5,6) - CSV of multiple ids.
Patel Nikhil
  • 185
  • 6
0
votes
1 answer

zend framework 2 understanding the exchangeArray method

From the documentation: namespace Album\Model; class Album { public $id; public $artist; public $title; public function exchangeArray($data) { $this->id = (!empty($data['id'])) ? $data['id'] : null; …
Gwen Hufschmid
  • 197
  • 1
  • 12
0
votes
1 answer

How to update an object in Zend Framework 2

i'm trying to update an object by using this code : The column co_nbre will be updated to 0 !!!! I think you will help me to fix this issue and thnx a lot. public function update($model) { $data = get_object_vars($model); $id = (int)…
0
votes
1 answer

Why does this error 1066 show up from join statesment

I have yet another issue. I am trying to join 2 tables so that i can pull data from both. I am new to TableGateway and am having issues finding the same situation. I have a page that will pull blogs by state and i also have a state table. I want to…
Scott Purtan
  • 181
  • 3
  • 13
0
votes
1 answer

Zend Framework 2 call TableGateway in Service

I'm new to ZF2. After few days of trying to figure out how all this stuff should work I was unable to figure out how should I call TableGateway Model from Service. So I have Controller: class SubscriberController extends…
metsys
  • 31
  • 1
  • 2
0
votes
1 answer

Does Zend TableGateway automatically cache duplicated queries?

I remember reading something similar about Symfony's Doctrine, but I can't find anything about this in Zend 2 documentation. Here is the question explained: Let's say that in a single controller action I call two model functions (both in same…
Vali Munteanu
  • 469
  • 3
  • 15
0
votes
1 answer

Zend Framework 2 Table Gateway USE INDEX

I'm using the ZF2 table gateway for a database select with following join: $select->join('feedback' , new Expression('feedback_id = feedbackcar_feedback_id') , ['provider_foreign_id' => 'feedback_action_provider_foreign_id'] ,…
KiwiJuicer
  • 1,952
  • 14
  • 28
0
votes
1 answer

ZF2 - Select with expression changes

in a project with 2.2.7 there is code like this: $select->where->expression('CXORDERNUMBER = "' . $orderNumber . '"', null); When trying to update this for 2.4.9 I get the following error: *Zend\Db\Sql\Exception\RuntimeException The number of…
Fesp
  • 127
  • 1
  • 13
0
votes
1 answer

Sql Query with Zend Framework 2 tableGateway

I'm new to Zend Framework 2 and I'm currently coding a Forum for a school project. I have a query that I can't manage with a Db Sql Select object and tableGateway. I just used a Db Adapter and it works fine but I'm looking for a way to pass my query…
0
votes
1 answer

Zend 2 : How to use a method defined in another model in my current model?

I try to solve this problem in different ways, but seems nothing is working. I have 2 models: namespace Admin\Model; use Zend\Db\TableGateway\TableGateway; class UsersMetaTable { protected $tableGateway; public function…
Andreea
  • 139
  • 12
0
votes
1 answer

Accessing 2 different tables from same controller file

I have successfully completed the the album table tutorial in Zend Framework 2 manual. I have implemented using tablegateway. I can see that he used only one table named "album" and hence he implemented according to that one table. Lets say I have…
Furquan Ul Haque
  • 15
  • 1
  • 1
  • 7
0
votes
1 answer

Using Zend tableGateway to INSERT on one table and UPDATE another

Supose you have a module called orders, which when it adds, It should update a value on another module (table of another module), and orders does include the id of the other module it its table. I plan on doing this with Zend's TableGateway, But I…