zend-db-select

How can I join a subquery using Zend_Db_Select

时光总嘲笑我的痴心妄想 提交于 2019-12-04 02:17:01
How would I construct this query using Zend_Db_Select? : SELECT users.user_id, email_address, t1.value as 'languages' FROM users LEFT JOIN ( SELECT user_id , field_id , GROUP_CONCAT(value SEPARATOR ',') AS value FROM user_multivalued WHERE field_id=25 GROUP BY user_id, field_id) t1 ON t1.user_id = users.users_id WHERE list_id = 45 Stephen Fuhry $user_multivalued = $db ->select() ->from('user_multivalued', array( 'user_id', 'field_id', new Zend_Db_Expr("GROUP_CONCAT(value SEPARATOR ',') AS value") )) ->where('field = ?', 25) ->group('user_id') ->group('field_id') ; $select = $db ->select() -

setIntegrityCheck in Zend Selects with joins

北战南征 提交于 2019-12-03 05:37:24
I was looking at some questions that ask how to do joins in Zend Framework queries, but the answer is always something like "just do setIntegrityCheck(FALSE) ". My question is: why do I need to do this? It seems to me disabling "integrity checks" is not the proper way of making this work. In my particular case, I'm using a MySQL database with some InnoDB tables with foreign keys, so for example: CREATE TABLE IF NOT EXISTS `tableA` ( `id` CHAR(6), `name` VARCHAR(255), PRIMARY KEY (`id`) ) ENGINE=InnoDB; CREATE TABLE IF NOT EXISTS `tableB` ( `tableA_id` CHAR(6), `somefield` VARCHAR(255), PRIMARY

Translating a query to use Zend_Db_Select

拜拜、爱过 提交于 2019-12-03 03:20:19
I'm having some problems translating this query to use ZF's Zend_Db_Select : SELECT b.id, b.title, b.description FROM memberships AS m JOIN blogs AS b ON b.id = m.blog_id WHERE m.user_id = ? ORDER BY m.created LIMIT 0, 30 (this query works and returns results) Memberships is a link table between blogs and users . It's a simple | id | blog_id | user_id | affair. Here's what I have so far: // $table = Zend_Db_Table instance, $id = a user id $select = $table->select() ->from(array('m' => 'memberships'), array('b.id', 'b.title', 'b.description')) ->join(array('b' => 'blogs'), 'b.id = m.blog_id') -