Questions tagged [zend-db]

Database access component for the Zend Framework.

for PHP 5 includes a database access component, referred to as Zend\Db.

The Zend\Db component includes features such as:

  • Database connection factory class.
  • Adapter for multiple brands of database, closely matching the interface, and also supporting other non-PDO database interfaces such as mysqli and oci.
  • Simple query builder for generic SELECT syntax.
  • statement profiler and logger.
  • Table Data Gateway and Row Data Gateway classes. Together these are similar to the popular Active Record pattern.

Resources:

  1. Github repository
1092 questions
3
votes
1 answer

How to work with many to many relations in Zend\Db (Zend Framework 2)

I have a ZF2 application that has database tables for posts and hash tags with a many-to-many relationship. The table definitions are: CREATE TABLE `hash_tag` ( `id` int(11) NOT NULL, `tag` varchar(255) NOT NULL ) CREATE TABLE `post` ( …
blainarmstrong
  • 1,040
  • 1
  • 13
  • 33
3
votes
2 answers

Magento Save make insert instead of update

I have a strange behaviour using Magento ( 1.4, old version I know) when I save a custom Model. $tr = Mage::getModel('Middleware/transfer')->load($transfer['transfer_request_id'], 'transfer_request_id'); …
Nicolas D
  • 1,182
  • 18
  • 40
3
votes
2 answers

mysql query to magento collection or writing a join subquery in magento

I have a db query which looks like SELECT f.forum_id, t.topic_id, MAX(p.post_id) AS `maxpostid`, p.admin_user_id, p.user_id, t2.topicscount, SUM(Maxp.postcount) AS postscount, CONCAT(au.firstname,' ',au.lastname) AS adminname, fu.nick_name…
Ahmed
  • 651
  • 17
  • 42
3
votes
3 answers

Zend Framework how to echo value of SUM query

I created a query for the zend framework, in which I try to retrieve the sum of a column, in this case the column named 'time'. This is the query I use: $this->timequery = $this->db_tasks->fetchAll($this->db_tasks->select()->from('tasks',…
Rick de Graaf
  • 968
  • 1
  • 14
  • 35
3
votes
1 answer

MySQL tables on iSeries / IBMDB2I

We are using the zendDBi database and are attempting to setup a MySQL table from an existing DB2 table. Using the method found here: http://wsip-174-79-32-155.ph.ph.cox.net/wiki/index.php/MySql/DB2StorageEngineDocument (in the section titled…
3
votes
1 answer

Zend Db Select add subquery to FROM part

I try to build a query with subquery in FROM part using the Zend_Db_Select. Im looking for somthing like this: SELECT COUNT(row_1) AS count_row FROM (SELECT row,row2,... FROM table WHERE row= ...) AS temp WHERE row = 0) So I try to do it like…
3
votes
1 answer

Catch an exception in a shutdown function

I'm working on some PHP code that needs to obtain a database resource, mark it as locked for the duration of its run and mark it as not locked when done. The lock is obtained at startup by updating a value in the table, and I've registered a…
GordonM
  • 31,179
  • 15
  • 87
  • 129
3
votes
2 answers

Conditional Fields Presentation

I have a table with 4 field named as Rowid,Customermainid,company,email. I wanna add class attribute to the particular row which satisfies the following condition Rowid > 28 for differentiate them I have searched a lot and get…
DRAJI
  • 1,829
  • 8
  • 26
  • 45
3
votes
1 answer

PHPUnit testing database with Zend_Test_PHPUnit_DatabaseTestCase and database adapter issue

I have implemented the abstract class from Database testing with Zend Framework and PHPUnit which implements Zend_Test_PHPUnit_DatabaseTestCase, however I am having issues with the way my database abstraction layer uses the Zend_Db_Adapter and how…
Jeremy Power
  • 161
  • 1
  • 7
3
votes
2 answers

Zend Framework: How to concatenate two columns and still use fetchPairs()?

I have a form with a select element that I need to populate with values from a database. Specifically, the name and id of the current users. The fetchPairs() function works great for this! However, I need to concatenate the value from the first_name…
Andrew
  • 227,796
  • 193
  • 515
  • 708
3
votes
2 answers

Zend Framework 2 Double Quotes in Queries

I'm using the Zend Framework 2 for application developement. The whole application is based on a IBM Informix database. The database configuration looks something like this: return array( 'db' => array( 'driver' => 'Pdo', 'dsn' …
kinkee
  • 368
  • 2
  • 12
3
votes
2 answers

Can I set a query timeout when using Zend_Db_Adapter_Pdo_Mssql?

We have a PHP application (hosted on Linux) which uses Zend Framework components to query a Microsoft SQL Server 2008 database. The PHP application is hosted in a datacenter with reliable internet connection, but the SQL Server database is at the…
Jim OHalloran
  • 5,859
  • 2
  • 37
  • 57
3
votes
1 answer

Zend Framework 2: Getting an ordered SQL call

I've been trying to get an order ASC/DESC call for a field (let's say craeted), and I can't seem to figure out how to do it in ZF2. Where am I going wrong..? namespace Todo\Model; class TodoTable extends AbstractTableGateway { public function…
Yossi
  • 1,056
  • 2
  • 13
  • 22
3
votes
1 answer

How can I turn ZF ->joinLeft()s into a Subquery?

How would i convert below query to sub query? I don't want to use JOINS I want to do same through sub query. i-e I need three subqueries out of the three joins. How it would be possible for below query ? protected $_name =…
Fawad Ghafoor
  • 6,039
  • 7
  • 41
  • 53
3
votes
2 answers

ZF2 + Zend\Db\Sql\Insert + ON DUPLICATE KEY UPDATE

I would like to insert some data using Zend\Db\Sql\Insert with the option ON DUPLICATE KEY UPDATE Actually I use this kind of query: INSERT INTO `user_data` (`user_id`, `category`, `value`) VALUES (12, 'cat2', 'my category value') ON DUPLICATE KEY…
Remi Thomas
  • 1,528
  • 1
  • 15
  • 25