Questions tagged [zend-db-table]

Object-oriented interface to database tables

The Zend_Db_Table class is an object-oriented interface to database tables. It provides methods for many common operations on tables. The base class is extensible, so you can add custom logic.

The Zend_Db_Table solution is an implementation of the Table Data Gateway pattern. The solution also includes a class that implements the Row Data Gateway pattern.

Official documentation

437 questions
40
votes
8 answers

How to make PDO run SET NAMES utf8 each time I connect, In ZendFramework

How to make PDO adapter run SET NAMES utf8 each time I connect, In ZendFramework. I am using an INI file to save the adapter config data. what entries should I add there? If it wasn't clear, I am looking for the correct syntax to do it in the…
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
36
votes
5 answers

Grouping WHERE clauses with Zend_Db_Table_Abstract

Does anyone know of a way to group where clauses with Zend_Db? Basically I have this query $sql = $table->select() ->where('company_id = ?', $company_id) ->where('client_email = ?', $client_email) …
Mark
  • 6,254
  • 1
  • 32
  • 31
26
votes
4 answers

When should use doctrine ORM and when zend-db-table?

In terms of project scale, doctrine vs zend-db-table speed and performance, when should I use doctrine inside Zend project, and when zend-db-table?
Ben
  • 25,389
  • 34
  • 109
  • 165
26
votes
3 answers

Zend Framework: How to delete a table row where multiple things are true?

Normally, this would work for me: $db = Zend_Db_Table::getDefaultAdapter(); $where = $db->quoteInto('id = ?', $id); $db->delete('tablename', $where); but I have to match two ids. So I don't really know how to structure it. WHERE first_id = 'id1'…
Andrew
  • 227,796
  • 193
  • 515
  • 708
22
votes
7 answers

How do I add more than one row with Zend_Db?

I have an array with information which looks more or less like this: $data[] = array('content'=>'asd'); $data[] = array('content'=>'asdf'); And I want to add both entries into the Database. $db->insert('table', $data); does not add both entries.…
Thomaschaaf
  • 17,847
  • 32
  • 94
  • 128
22
votes
2 answers

Zend framework - Why should I use data mapper / Db_Table_Row?

Extended Question: Why should I use data mapper / Db_Table_Row, where as DbTable is capable of handling most of the basic tasks for data manipulation. I am currently learning ZF v1.11 For Database manipulation, I created DbTable for each tables. For…
Hossain Khan
  • 6,332
  • 7
  • 41
  • 55
14
votes
7 answers

avoiding MySQL injections with the Zend_Db class

I currently use Zend_Db to manage my queries. I've written already code that preforms queries like the one below: $handle->select()->from('user_id') ->where('first_name=?', $id) ->where('last_name=?',…
daniel
  • 1,212
  • 1
  • 18
  • 33
13
votes
4 answers

Zend Framework: How to retrieve the id of the last inserted row?

I'm inserting a new row into my database with this code: $data = array( 'key' => 'value' ); $this->getDbTable()->insert($data); How can I get the row id of the this row that I just created?
Andrew
  • 227,796
  • 193
  • 515
  • 708
12
votes
5 answers

Cannot refresh row as parent is missing. Zend Framework

i am getting the error "Cannot refresh row as parent is missing" when I try to save. Here is my code abstract class Webapp_Model_Resource_Db_Table_Abstract extends Zend_Db_Table_Abstract { /** * Save a row to the database * * …
browndash
  • 123
  • 1
  • 6
12
votes
4 answers

How do I add complex where clause to Zend Table Select?

I searched the Web and could not find anything that would show me a good solid example. My question is basically this: How do I convert this: SELECT * FROM table WHERE ((a = 1 AND b = 2) OR (c = 3 OR c = 4)) AND d = 5; To Zend syntax similar to…
AD.
  • 237
  • 2
  • 3
  • 12
12
votes
7 answers

Zend_Db: How to get the number of rows from a table?

I want to find out how many rows are in a table. The database that I am using is a MySQL database. I already have a Db_Table class that I am using for calls like fetchAll(). But I don't need any information from the table, just the row count. How…
Andrew
  • 227,796
  • 193
  • 515
  • 708
11
votes
7 answers

How can I escape complex sql in Zend Framework?

I have the following sql (a simplification of the real problem): SELECT * FROM t WHERE myname LIKE '%{$input}%'; How do I escape the $input? I can't use the quoteInto (unless I miss something). As $sql=$DB->quoteInto("SELECT * …
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
11
votes
3 answers

Zend DB Selecting constants - columns that do not exist in table

I'm trying to do this query using Zend DB select but I'm not able to do so This is the sql query select shopping_id,shopping_details,"friend" as type from shopping Notice here how I'm specifying "friend" as type and friend is not a column in the…
Gublooo
  • 2,550
  • 8
  • 54
  • 91
10
votes
5 answers

How can I Select the MAX of a Column using Zend_Db_Table?

What is the easiest, simplest way to select the max of a column from a table using Zend_Db_Table? Basically, I just want to run this query in Zend: SELECT MAX(id) AS maxID FROM myTable;
Daniel Bingham
  • 12,414
  • 18
  • 67
  • 93
10
votes
3 answers

Zend Framework: Proper way to interact with database?

I'm fairly new to the Zend Framework and MVC and I'm a bit confused by Zend_DB and the proper way to interact with the database. I'm using the PDO MySQL adapter and have created some classes to extend the abstract classes: class Users extends…
Gilean
  • 14,708
  • 10
  • 45
  • 52
1
2 3
29 30