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
9
votes
2 answers

Zend Framework 2 Sql Select with OR and AND

I want to make this query using Zend\Db\Sql\Select: SELECT table1.* FROM table1 INNER JOIN table2 ON table1.columnA = table2.columnB INNER JOIN table3 ON table1.columnC = table3.columnD WHERE (table2.column2 = 2 or table3.column3 = 3) and…
leticia
  • 2,390
  • 5
  • 30
  • 41
9
votes
1 answer

Using Zend Framework Db Tables without MVC

I am trying to use the Zend Framework without using the MVC structure, specifically the Db_Table classes. I have created a couple of classes representing my database tables, i.e. class DBTables_Templates extends Zend_Db_Table_Abstract { …
Stuart
  • 3,258
  • 4
  • 29
  • 39
8
votes
1 answer

Zend framework group by

I'm trying to do a group by using Zend framework. Here's my code: $table = new TableClass(); $select = $table->select(); $select->from ("table", array("date", "column1" => "sum(column1)")); $select->group ( array ("date") ); $results =…
user370838
8
votes
1 answer

Using \Zend_Db_Table_Abstract::find($id). MySQL SET field returns string instead of (wanted) int

Basic question How can I fetch the 'type' column as integer value from inside the table mapper? I have a PHP Zend Framework 1.12 application running a website. Inside MySQL are multiple tables with multiple columns. Inside two tables I use the SET…
Benz
  • 2,317
  • 12
  • 19
8
votes
1 answer

Zend Db avoiding sql injections

I have the following code: public function checkLoginDetails($email, $password) { $select = $this->select (); $select->where ( "password=?", md5($password) ); $select->where ( "email=?", $email ); return…
iBiryukov
  • 1,730
  • 4
  • 19
  • 30
8
votes
4 answers

ZF2 Zend\Db Insert/Update Using Mysql Expression (Zend\Db\Sql\Expression?)

Is there any way to include MySQL expressions like NOW() in the current build of ZF2 (2.0.0beta4) through Zend\Db and/or TableGateway insert()/update() statements? Here is a related post on the mailing list, though it hasn't been answered:…
Alex Ross
  • 3,729
  • 3
  • 26
  • 26
7
votes
5 answers

Is there a way to get the number of records from a query with Zend-framework?

Given my generic select below, is there a way to get the number of records returned from a query with Zend Framework? $row++ in a loop is not acceptable for my solution as I am using paging (though its not in my sample). I also DO NOT want to add…
Kladskull
  • 10,332
  • 20
  • 69
  • 111
7
votes
3 answers

Zend Enable SQL Query logging

I am using this to retrieve the database connection atm. $db = Zend_Db_Table::getDefaultAdapter(); I do set this up in my config like this: resources.db.adapter = pdo_mysql resources.db.isDefaultTableAdapter = true resources.db.params.host =…
Oldek
  • 2,679
  • 5
  • 23
  • 25
7
votes
1 answer

Zend Select NOT IN

I have two tables with related data, and I want to select all the records from one table which do not exist in the other table, plus some other criteria on the related table, as follows (123 is just for illustration purposes): TABLE A ID …
Elie
  • 13,693
  • 23
  • 74
  • 128
7
votes
1 answer

PHPUnit and ZF2 Services

I have a little problem when creating tests with PHPUnit. Here is my setup : protected function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); …
Amelie
  • 516
  • 3
  • 17
7
votes
1 answer

Select query cannot join with another table - JOIN Zend Framework

An error occurred Application error Exception information: Message: Select query cannot join with another table This is my code:
Jhosman
  • 555
  • 2
  • 8
  • 20
7
votes
2 answers

Zend Db Select ? Substitution in join* condition

It doesn't look like there's any parameter substitution in Zend_Db_Select's on clause. It's highly annoying that I can't just do something like: $select->joinLeft('st_line_item','st_line_item.order_id = st_order.id and st_line_item.status = ?') So…
Koobz
  • 6,928
  • 6
  • 41
  • 53
7
votes
1 answer

ZF2 + Zend\Db\Sql\Update, adding to current value

I'm trying to do something relatively simple but can't figure it out. I just want to add to a current value in the DB is there anyway to do the equivalent of a: UPDATE `tablename` SET fieldB = fieldB + 1 WHERE fieldA='X' Using the Zend/db update…
Juan
  • 178
  • 2
  • 9
7
votes
3 answers

Zend: How to insert NULL values into MySQL

I am using Zend Framework with MySQL,Apache and Ubuntu 9.04. I am trying to insert NULL values into database like this: $personObj->setPersonId( '1' ); $personObj->setPersonEmail('NULL'); $personObj->save(); But 'NULL' is stored in database as…
Naveed
  • 41,517
  • 32
  • 98
  • 131
7
votes
1 answer

Executing multiple join with expressions on Zend Framework 2

Actually I'm working on a project and I'm looking on how Zend Framework 2 handle complex queries (expecially on how to join n:m tables and how to use GROUP_CONCAT and other functions). Do you know the best practice to execute this query: SELECT o. *…
DreaMin
  • 75
  • 2
  • 5
1 2
3
72 73