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

How to display image while updating the information

I want to display images while editing the information of the user. I just bind the form with fetched data and displaying all data with single array i.e form. Also is there any way to get https 500 error? If yes then please show me some code so that…
Dev5
  • 67
  • 2
  • 10
1
vote
1 answer

Dynamically access object property by using "$this"

I have next lines in my code to get the entity in ZF3: $entity = $this->userCredentialsTableGateway ->getResultSetPrototype() ->getArrayObjectPrototype(); To automate it for different tables I created a…
Kereell
  • 69
  • 7
1
vote
1 answer

How to perform a pre select in zf2

I have a AbstractTableGateway like this: class FundsTable extends AbstractTableGateway { protected $table = 'tb_funds'; public function __construct(AdapterInterface $adapter) { $this->adapter = $adapter; $this->resultSetPrototype = new…
1
vote
2 answers

zend Framework 2 update query by TableGateway Object

public function update($table, $where = array(), $data_arr = array()){ print_r($data_arr); $adapter = $this->tableGateway->getAdapter(); $projectTable; if($table != null){ $projectTable = new TableGateway($table,…
1
vote
1 answer

Zf2 table gateway join query to fetch only the latest row(by id) from second table

Hi, I need a zf2 join query that fetches only the latest row(by id DESC) from the second table. I have written an sql query and it works. SELECT st1.customer_id, st1.id FROM status st1 inner JOIN ( SELECT max(id) MaxId, customer_id …
murad
  • 175
  • 2
  • 14
1
vote
1 answer

ZF2 - Join with TableGateway inside Model Table

How can I do a JOIN inside a Model Table with TableGateway? I have this in my Model/NoticiasTable.php: protected $tableGateway; public function __construct(TableGateway $tableGateway) { $this->tableGateway = $tableGateway; } public…
1
vote
1 answer

Generate a somewhat complex query with joins on subqueries in the FROM clause using zend framework 2 tableGateway

I'm trying to generate the following query using Zend Framework 2 tableGateway. SELECT dfsstamp, dfcstamp, df_rstrd_flg, dfctid, dfname, dfloc, dfdesc, dfcuser, dfmuser, dfid AS, t2.dfdfid, ctname, cafldnme, caid, atid, atvalue,…
Rodney
  • 250
  • 3
  • 14
1
vote
2 answers

Pre functions for TableGateway in zend framework 2 (zf2)

I am using table gateway in zf2. This is simple model table with following working functions. I can insert or update records but I need to know how can we define functions like beforeInsert or beforeUpdate like we do in…
1
vote
1 answer

How to select particular columns with ORDER BY clause in zend framework2

I'm new to zend framework and i know this is a beginner level question.But i'm totally messed up. I want to retrieve only user_id and user_name form database with descending order of user_id. I'm using tablegateway. I'm calling getUsersTable()…
nilesh
  • 99
  • 2
  • 10
1
vote
1 answer

Can't retrieve id value when using Zend TableGateway's select()

I try to show all the content I have in MySql table by using TableGateway's select() method:

Users

tableGateway; $rowset = $tableGateway->select(); foreach…
1
vote
1 answer

Creating an instance of Zend\Db\TableGateway using service manager

I have been trying to create an instance of Zend\Db\TableGateway but just can't get it right. This is what I have in my module.php: use Question\Model\QuestionsTable; use Zend\Db\ResultSet\ResultSet; use Zend\Db\TableGateway\TableGateway; //other…
Joss
  • 57
  • 9
1
vote
1 answer

Zend Framework 2 TableGateway fetchAll method returns empty result set but the table contains data

I would like to ask some help regarding TableGateway in Zend Framework 2. Basically, I followed the tutorial step-by-step making small modifications but I don't know where I missed something. The issue described below platform-independent, I was…
AndrasCsanyi
  • 3,943
  • 8
  • 45
  • 77
1
vote
3 answers

Zend:Fetching Data from Multiple tables

Please find my code below module.php public function getServiceConfig() { return array( 'factories' => array( 'Shopping\Model\ShopTable' => function($sm) { $tableGateway = $sm->get('ShopTableGateway'); $table = new…
Friend
  • 1,326
  • 11
  • 38
  • 62
1
vote
1 answer

Zend Paginator+Table Gateway: error

Error: elements of paginator are objects (not arrays). var_dump($records): object(Records\Model\Records)#240 (11) { ["id"]=> NULL ["name"]=> string(9) "5453gdfgd" ["email"]=> string(16) "igor@bk.ru" ["homepage"]=> string(0) "" ["text"]=> string(5)…
1
vote
1 answer

Zf2 TableGateway

Need help understanding why I can't query my database without using the ServiceManager or maybe it's something else I'm doing wrong. My approach is probably not recommended but your answers would help me better understand the framework. My Model is…
Ori
  • 154
  • 1
  • 8