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

Retrieve a last inserted user_id in zend db

How to retrieve last inserted user id? I have to use that user id for inserting that user id into next query that also should be done in this transaction only. my query: $db->beginTransaction (); $sql = $db->query ( "INSERT INTO user( user_id,…
vvr
  • 456
  • 3
  • 17
  • 30
3
votes
0 answers

'Zend_Db_Statement_Exception' with message 'Invalid bind-variable name ':1'

Good day, Background Info: Client's hosting server is being upgraded from PHP 5.2 to PHP 5.3. The client's app breaks when tested on PHP 5.3. Specifically the insert and update methods are the ones which are breaking the app. The app coded in Zend…
3
votes
1 answer

Zend_Db Question... updating an incrementor

Should this work? (increment the login count?) // update the login count $data = array( 'logins' => 'logins + 1' ); $n = $db->update('users', $data, 'user_id = '.$_userId);
Kladskull
  • 10,332
  • 20
  • 69
  • 111
3
votes
2 answers

Multiple Conditions with Left Join in Zend Framework

I am facing an issue while working with Zend Framework. Basically, I am trying to add an AND operator in a sub query using Left join. Please see the following query that my code is producing: SELECT `d`.*, count(status) FROM `deal` AS `d` LEFT JOIN…
user1105983
  • 41
  • 1
  • 3
3
votes
1 answer

Bulk insert into DB with Zend

I've seen on SO that you can do multiple inserts without having to do them in a loop, with the createRowset and createRow methods. My problem is, that I'm not sure in which class the createRowset method is defined. I have the following code, which…
Eduard Luca
  • 6,514
  • 16
  • 85
  • 137
3
votes
1 answer

Zend_Db_Table joined queries vs database view

I was wondering what would be the best practices and the best way to achieve consistency while accessing your database data : Current structure goes as follow Data Access --> Business Logic --> Controller --> View My data access layer is composed…
JF Dion
  • 4,014
  • 2
  • 24
  • 34
3
votes
2 answers

Adding a WHERE clause to Zend_Validate_Db_NoRecordExists

I am using Zend_Validate_Db_NoRecordExists detailed in the link below to check if a record exists before inserting it. I have no issues with the basic code and have got it working fine, what I need to do next is add a WHERE clause to exclude records…
jjmu15
  • 98
  • 8
3
votes
2 answers

Local "Cache" for Zend_Db_Row subclasses

Across our application, we use subclasses of Zend_Db_Row to represent objects in our application. these objects are being returned by various fetch functions.
aporat
  • 5,922
  • 5
  • 32
  • 54
3
votes
2 answers

How to check if Zend_Db_Adapter_Pdo_Mysql object is connected to a database

Am developing a Zend application where i need to keep a single instance of the database object and reconnect if the current instance is somehow disconnected. Here is the code: class Resource_PdoMysql extends…
Markel Mairs
  • 742
  • 2
  • 10
  • 28
3
votes
1 answer

How do I use a "HAVING" clause in a Zend_Db_Select statement without parenthesis?

I know Zend provides a having() method, but what I want is a query like: SELECT a.*, `as`.* FROM `fruit_db`.`apples` AS `a` INNER JOIN `fruit_db`.`apple_seeds` AS `as` ON a.id = as.apple_id WHERE (a.id = 1) AND as.seed_name HAVING 'johnny' not…
thecheese
  • 31
  • 1
  • 3
3
votes
2 answers

How can Zend_Db be used to update multiple tables using joins?

Is there an equivalent to the following SQL using the Zend_Db modules? UPDATE items,month SET items.price=month.price WHERE items.id=month.id; The mysql manual states ... multiple-table UPDATE statements can use any type of join permitted in …
Shoan
  • 4,003
  • 1
  • 26
  • 29
3
votes
1 answer

Modelling in Zend framework

I'm working on a large project at the moment and am just wondering which is best practice, to model entities and sets of entities seperately or in one class? Currently I am implementing two classes for each entity (for example an 'author' and…
Rob Ganly
  • 403
  • 2
  • 5
  • 14
3
votes
2 answers

Zend DB Table Abstract

I've hit a bit of a brick wall in converting an SQL Query into a suitable ORM Query The query is pretty complex even in SQL Terms, But I am looking at ways of collating this into an ORM Query, as I'm converting a lot of functions I've produced in…
StuBlackett
  • 3,789
  • 15
  • 68
  • 113
3
votes
2 answers

Zend_Db_Select: LEFT JOIN on a subselect

I have a query, that does a LEFT JOIN on a subselect. This query is run in a high load environment and performs within the set requirements. The query (highly simplified) looks like: SELECT table_A.pKey , table_A.uKey , table_A.aaa , table_B.bbb ,…
Jacco
  • 23,534
  • 17
  • 88
  • 105
3
votes
3 answers

How to model multilingual database with Zend, l18n mysql?

I know this topic was discusses a couple of times, but none of them represents the ultimate solution for me. Situation I'm designing a relational mysql database which later should hold multilingual content. You know this from the Wikipedia or…
Manuel
  • 9,112
  • 13
  • 70
  • 110