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

How do left outer joins work on Zend framework

I have this SQL query: SELECT pais FROM pais LEFT OUTER JOIN users_has_pais ON pais.id = users_has_pais.pais_id WHERE users_has_pais.users_id = 100 And I'm trying to write something similar within a model using the leftJoin method from…
la_f0ka
  • 1,773
  • 3
  • 23
  • 44
4
votes
2 answers

How to paginate two tables in zend framework

Books has the following fields book_id book_name book_auther book_pub_date category table has category_id category_name placement table has placement_id placement_category_id(FK) placement_book_id(FK) Now we want to use pagination in index…
3ehrang
  • 619
  • 1
  • 7
  • 22
4
votes
2 answers

How to set default port on MySQL for Mac

On OSX when I try to use the following: resources.db.adapter = "pdo_mysql" resources.db.params.dbname = "myDb" resources.db.params.host = "localhost" resources.db.params.username = "root" resources.db.params.password = "" I get the following…
chrisan
  • 4,152
  • 4
  • 28
  • 32
4
votes
1 answer

Using a Zend_Db_Expr

I have the following query: $select = $this->getDao()->select() ->from( array(new Zend_Db_Expr('FROM_UNIXTIME(expiration)')) ); The getDao function is a reference to my…
sanders
  • 10,794
  • 27
  • 85
  • 127
4
votes
3 answers

PHP implode array to generate mysql IN criteria

I have a function like the following: public function foo ($cities = array('anaheim', 'baker', 'colfax') ) { $db = global instance of Zend_Db_Adapter_Pdo_Mysql... $query = 'SELECT name FROM user WHERE city IN ('.implode(',',$cities).')'; …
Mr Griever
  • 4,014
  • 3
  • 23
  • 41
4
votes
2 answers

Zend db adapter mysqli or PDO_MYSQL

I've seen several code samples that do this in application.ini resources.db.adapter = mysqli or resources.db.adapter = PDO_MYSQL What is the real difference between the two? Does it impact my code? when should I choose one or the other?
jblue
  • 4,390
  • 4
  • 46
  • 79
4
votes
3 answers

Building a select distinct on mysql ( zend_db)

I HAVE THE FOLLOWING TABLE, I WOULD LIKE TO GET to do a select distinct on the the column [code], i don't need to get the "A" three times. [ ID ] [ CODE ] [ LIBELLE ] 1 A LIBELLE1 2 B LIBELLE2 3 C …
Mamadou
  • 2,177
  • 5
  • 31
  • 43
4
votes
3 answers

MySQL remove space before order by clause

I have a table full of "title" that I want to order by title. Problem is a lot of them have a empty space before the title. I am thinking of writting a php script to fix it all (super easy) but I was curious how could I do: SELECT * FROM products…
Iznogood
  • 12,447
  • 3
  • 26
  • 44
4
votes
4 answers

Zend DB and encoding

I have just encountered something rather strange, I use the Zend Framework 1.10 with the Zend_Db_Table module to read some data from a databse. The database itself, the table and the fields in question all have their collation set to…
Robin
  • 8,197
  • 11
  • 45
  • 74
4
votes
2 answers

Getting table object(App_Model_TableName) as fetch result (Zend Framework)

Right now, I'd wrote a function in my model as: public function getRowsByZipCode($zip) { // SQL to get all the rows with the given zip code $stmt = $this -> getAdapter() -> query( "SELECT * …
Pushpendra
  • 4,344
  • 5
  • 36
  • 64
4
votes
2 answers

Multiple/nested "select where" with Zend_Db_Select

Possible Duplicate: Grouping WHERE clauses with Zend_Db_Table_Abstract I need to create something like this: select name from table where active = 1 AND (name LIKE 'bla' OR description LIKE 'bla') The first part is easy: $sqlcmd =…
Reyo
  • 148
  • 3
  • 11
4
votes
3 answers

Using case/when/then in SQL queries of Zend Framework 2

I have query : SELECT user_name, group_id, CASE WHEN col_1 = 1 THEN 0 WHEN col_2 = 1 THEN 1 WHEN col_3 = 1 THEN 2 END as merge_col FROM some_table WHERE group_id = 10 ORDER BY merge_col. How using ZF2 and…
Maksym Kalin
  • 1,693
  • 16
  • 18
4
votes
2 answers

Zend Framework: How to find a table row by the value of a specified column?

I am implementing my model exactly like the quickstart guide. In my model I am trying to implement a findByToken() method. The current find() method accepts an $id parameter, but I want to find by the value of a different column. //excerpt from the…
Andrew
  • 227,796
  • 193
  • 515
  • 708
4
votes
2 answers

how to return an array of objects in zend framework 2?

I am doing a query in zf2 and i get back a object(Zend\Db\ResultSet\HydratingResultSet) that i have to a foreach on, in order to get to the properties. I would like to get an array of objects by default. here is some code i…
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
4
votes
3 answers

Zend_Db and Date Based Queries

I'm using Zend_Db to query a table. I have some WHERE clauses that need to be dates and it's not clear (at first glance) how to do this "the right way". Does Zend_Db provide an abstraction so I don't need to concern myself with how the backend…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599