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

Zend selects all columns

In the following code: $selectColumns= array('user_id.user_email', // inner join the data from user_id and user_details 'user_details.first_name', 'user_details.last_name'); $result =…
robertashcroft
7
votes
2 answers

zend not using columns, and selecting everything

I have the following code $result = $handle->select()->from('store_details') ->where('store_details.store_id=?', $id) ->columns('store_details.store_name'); …
daniel
  • 1,212
  • 1
  • 18
  • 33
6
votes
3 answers

Example of a Multi Condition Delete with Zend framework

Can someone give me an example of how I would delete a row in mysql with Zend framework when I have two conditions? i.e: (trying to do this) "DELETE FROM messages WHERE message_id = 1 AND user_id = 2" My code (that is failing miserably looks like…
Kladskull
  • 10,332
  • 20
  • 69
  • 111
6
votes
2 answers

Using concrete Zend_Db_Table_Abstract to efficiently iterate through a rowset

I'm using a concrete implementation of Zend_Db_Table_Abstract: class DB_TestClass extends Zend_Db_Table_Abstract { protected $_name = "test.TestData"; } If I want select all rows in the table, I seem to have one option: $t = new…
6
votes
7 answers

Zend_Validate_Db_RecordExists against 2 fields

I usualy use Zend_Validate_Db_RecordExists to update or insert a record. This works fine with one field to check against. How to do it if you have two fields to check? $validator = new Zend_Validate_Db_RecordExists( array( …
cwhisperer
  • 1,478
  • 1
  • 32
  • 63
6
votes
3 answers

Zend_Db without Zend Framework

I want using Zend_Db without Zend_Framework. I want incorporate Zend_Db for my existing website that was not made using Zend Framework. Is it possible to use Zend_Db like this? Can you recommend good tutorial or example how to do it good?
user594791
  • 617
  • 1
  • 8
  • 15
6
votes
2 answers

how to build multiple insert query in zend framework

Possible Duplicate: How do I add more than one row with Zend_Db? i would like to build this query INSERT INTO ad-page (ad_name, page_name) VALUES ('value1', 'value2'), ('value3', 'value4') , .... i tried this which did not work …
S L
  • 14,262
  • 17
  • 77
  • 116
6
votes
4 answers

[zend][db] fetchAll with multiple variables

I'm trying to use fetchAll on a query that has 2 variables. I can't figure out the syntax. I can manage with only 1 variable: $sql = "SELECT * FROM mytable WHERE field1 = ?"; $this->_db->fetchAll($sql,$value1); # that works However I'm having some…
Max
  • 12,794
  • 30
  • 90
  • 142
6
votes
2 answers

Zend Framework: How to do a DB select with multiple params?

I'm just wondering what the syntax is to do a db select in Zend Framework where two values are true. Example: I want to find if a user is already a member of a group: $userId = 1; $groupId = 2; $db = Zend_Db_Table::getDefaultAdapter(); $select = new…
Andrew
  • 227,796
  • 193
  • 515
  • 708
6
votes
5 answers

SQL: Insert only new rows/records into a table?

I'm parsing a json feed routinely and need to insert only the newest users from the feed and ignore existing users. I think what I need is ON DUPLICATE KEY UPDATE or INSERT IGNORE based on some searching but I'm not quite sure which is why I'm…
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
6
votes
2 answers

Zend Framework 2 - Applications / Modules / Service Managers - Oh My

I have just started learning Zend Framework 2 as a long time Zend Framework 1 developer. I am having a little trouble wrapping my head around the new terminology. Back in ZF1, if I wanted to create a logger that was global to an application I would…
Aaron Murray
  • 1,920
  • 3
  • 22
  • 38
6
votes
1 answer

Select a dummy column with a dummy value in Zend framework Select?

How can i specify Zend Db Table Select to fetch a dummy column. i want to generate sql like this SELECT 'ABC' AS xyz , name FROM employee Edit: I have tried this $select->from('employee',array( 'xyz'=>'ABC', 'name' )); and also…
Rasikh Mashhadi
  • 1,422
  • 1
  • 15
  • 25
5
votes
4 answers

mysql_real_escape_string with Zend

I am developing a web application using zend framework. For select statements I have used following way. Ex: public function getData($name) { $sql = "SELECT * from customer where Customer_Name = '$name'"; return…
Prasad Rajapaksha
  • 6,118
  • 10
  • 36
  • 52
5
votes
3 answers

How to use union in zend db

In sql i am using union i don't know how to write it in zend db. select m.*, 0 as is_shared from test m where user_id = $userId union select m.*,1 as is_shared from test m join test_shares ms where m.test_id = ms.test_id and ms.email_address =…
vvr
  • 456
  • 3
  • 17
  • 30
5
votes
1 answer

Zend Framework generate unique string

I want to generate a unique 4-6 char long AlphaNumeric string to save in db with each record(user). The db field has a unique index, so trying to save a pre-existing string generates an error. Right now I am generating a random string and using…
Bryan
  • 645
  • 1
  • 6
  • 18