zend-db-table

Zend_Db_Table subquery

不想你离开。 提交于 2019-11-28 12:27:11
I have a some SQL that I want to use with ZendFW, but I can't get it working and it's driving me crazy. I get the correct result with this query: SELECT DISTINCT e.festival_id FROM entries AS e, mail_log as m WHERE e.status = 1 AND e.festival_id NOT IN (SELECT m.entry_id FROM entries AS e, mail_log as m WHERE m.entry_id = e.festival_id) Help would be appreciated. Cheers :) Goran's answer is the best answer. But if you want a zend_db_table style query, this would be an alternative: $sql = $table->select() ->setIntegrityCheck(false) ->from('entries', new Zend_Db_Expr('DISTINCT festival')) -

How do I add more than one row with Zend_Db?

走远了吗. 提交于 2019-11-28 05:25:37
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. What am I doing wrong? Do I have to use Zend_ Db_Table? $data = array('content'=>'asdf'); $db->insert('table', $data); works of course markus I don't think Zend_Db supports insertion of multiple rows. But if you just have two rows or a little more you can just use a loop. foreach ($data as $row) { $db->insert('table', $row) } Bill Karwin , a former

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

亡梦爱人 提交于 2019-11-27 20:06:20
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' AND second_id = 'id2' So how do I do this with the Zend Framework? To extend on Jason W's answer: Not exactly sure what the 3rd section is saying That means you can do this: $db->delete('tablename', array( 'first_id = ?' => $first_id, 'second_id = ?' => $second_id )); And the adapter will quote everything for you. I don't feel like the documentation is

Zend Enable SQL Query logging

最后都变了- 提交于 2019-11-27 18:37:22
问题 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 = localhost resources.db.params.username = root resources.db.params.password = password resources.db.params.dbname = db resources.db.params.profiler.enabled = true resources.db.params.profiler.class = Zend_Db_Profiler I would like to output everything to a

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

谁说我不能喝 提交于 2019-11-27 12:51:52
问题 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? 回答1: Any ORM framework gives you benefit for development productivity, not runtime efficiency. Doctrine is no different from Zend_Db_Table in this regard. If you are choosing between Doctrine and Zend_Db_Table, choose based on the features that make it easier or faster to write the code. No ORM framework can automatically make database queries

avoiding MySQL injections with the Zend_Db class

不羁的心 提交于 2019-11-27 12:11:56
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=?', $lname) I've done this without sanitizing the input, assuming Zend_Db will. Does Zend do this? Another question: Does Zend_Db sanitize insert('table', $data) and update queries? Thanks. I wrote a lot of the code for database parameters and quoting in Zend Framework while I was the team lead for the project (up to version 1.0). I tried to encourage best practices where possible, but I had to

Grouping WHERE clauses with Zend_Db_Table_Abstract

做~自己de王妃 提交于 2019-11-27 11:47:19
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) ->orWhere('client_email_alt = ?', $client_email); Which is giving me this: SELECT `clients`.* FROM `clients` WHERE (company_id = '1') AND (client_email = 'email@address.com') OR (client_email_alt = 'email@address.com') But I need it to give me this, where the OR statement is grouped: SELECT `clients`.* FROM `clients` WHERE (company_id = '1') AND ((client_email = 'email@address.com') OR (client_email

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

久未见 提交于 2019-11-27 10:53:47
问题 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 example, "users" table is represented by Application_Model_DbTable_Users with no additional codes in there. When manipulating data, I can use: <?php $uTable = new Application_Model_DbTable_Users(); $newUid = $uTable->insert(array('name'=>'Old Name

Zend_Db_Table subquery

旧时模样 提交于 2019-11-27 07:01:18
问题 I have a some SQL that I want to use with ZendFW, but I can't get it working and it's driving me crazy. I get the correct result with this query: SELECT DISTINCT e.festival_id FROM entries AS e, mail_log as m WHERE e.status = 1 AND e.festival_id NOT IN (SELECT m.entry_id FROM entries AS e, mail_log as m WHERE m.entry_id = e.festival_id) Help would be appreciated. Cheers :) 回答1: Goran's answer is the best answer. But if you want a zend_db_table style query, this would be an alternative: $sql =

Grouping WHERE clauses with Zend_Db_Table_Abstract

三世轮回 提交于 2019-11-27 04:03:24
问题 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) ->orWhere('client_email_alt = ?', $client_email); Which is giving me this: SELECT `clients`.* FROM `clients` WHERE (company_id = '1') AND (client_email = 'email@address.com') OR (client_email_alt = 'email@address.com') But I need it to give me this, where the OR statement is grouped: SELECT `clients