Questions tagged [zend-db-select]
117 questions
4
votes
1 answer
MySQL Query - Select all posts and count comments for each one
It's 3:30 AM in my country so I need to sleep but I can't without this:
I'm trying to get all posts (using Zend_Db) and count comments for each one.
Schema
blog_posts:
+---------------+------------------+------+-----+---------+----------------+
|…

Frederick Marcoux
- 2,195
- 1
- 26
- 57
4
votes
1 answer
How to convert normal sql query to Zend_Db_Select?
Hi I want to convert my normal mysql query to zend.db.select;
I want to use this script:
$select = $db->select();
// Add a FROM clause
$select->from( ...specify table and columns... )
// Add a WHERE clause
$select->where( ...specify search…

devrez
- 103
- 4
- 12
4
votes
4 answers
convert Zend Db Select query to sql query
Are there any ways to convert Zend db Select or Zend DB query to SQL query before querying the database? Any other workarounds?
As I want to build a more complex SQL query that Zend DB cannot handle, without modifying my current Zend db code…

Capitaine
- 1,923
- 6
- 27
- 46
3
votes
2 answers
Zend_Db_Select: LEFT JOIN on a subselect
I have a query, that does a LEFT JOIN on a subselect. This query is run in a high load environment and performs within the set requirements. The query (highly simplified) looks like:
SELECT
table_A.pKey
, table_A.uKey
, table_A.aaa
, table_B.bbb
,…

Jacco
- 23,534
- 17
- 88
- 105
3
votes
1 answer
How can I use MySQL GROUP BY modifier WITH ROLLUP in Zend_Db_Select?
The SQL query in my web application(PHP/MySQL + Zend) uses a number of parameters to build the search query. However, the records fetched should be grouped by two columns to get sub totals. WITH ROLLUP seems to be a good solution to find subtotals,…

libregeek
- 1,264
- 11
- 23
3
votes
1 answer
Zend Framework: Re-use WHERE clause returned from Zend_Db_Select::getPart()
I have a SELECT object which contains a WHERE.
I can return the WHERE using getPart(Zend_Db_Select::WHERE), this returns something like this:
array
0 => string "(clienttype = 'agent')"
1 => string "AND (nextpayment < (NOW() - INTERVAL 1…

Jake N
- 10,535
- 11
- 66
- 112
3
votes
2 answers
How to join two tables in Zend and read the resulting data
I have the following query:
$usersTable = new Users();
$rowset = $usersTable->select()
->setIntegrityCheck(false)
->where( 'id = ?', $userId )
->join( 'Books', 'Books.userid = Users.id' );
However, I can't for the life of me figure out…

romiem
- 8,360
- 7
- 29
- 36
3
votes
1 answer
When to use which Zend_Db class? Zend_Db_Select vs. Zend_Db_Table_Abstract
I think it's possible to write select queries with either Zend_Db_Select or Zend_Db_Table_Abstract, but I don't understand when to use which of the two.
Is one more optimized for something than the other? Are joins "easier" with one or the…

Niels Bom
- 8,728
- 11
- 46
- 62
3
votes
2 answers
Zend Framework 1.12 Db Select - nested WHEREs using multiple values for question marks in condition
I'm using Zend Framework 1.12.3. I need to create a query that hasnested WHEREs, such as
SELECT * FROM table1
WHERE (id = 'foo' AND name = 'bar') OR (grade = 123)
Here's my attempt
$this->getDbTable()->select()
->from($this->getDbTable(),…

Daniel
- 667
- 6
- 19
3
votes
1 answer
Need dynamic column information from Zend Paginator Object
I am building a plugin for grid listing ( for my personal use of course ). Now I integrated ZF2 Paginator as in link http://framework.zend.com/manual/2.1/en/tutorials/tutorial.pagination.html . I am using DB Select for Paginator (Not Array). I need…

kuldeep.kamboj
- 2,566
- 3
- 26
- 63
2
votes
1 answer
Rewrite sql query to Zend_Db_Select
I'm trying to build the following sql query as a Zend_Db_Select object
$sql = "
SELECT
u.id,
u.email,
s.nic as nic,
(SELECT COUNT(*) FROM event WHERE user_id = u.id AND event='login') as logins,
(SELECT…

Tor Inge Schulstad
- 78
- 5
2
votes
2 answers
Zend DB Select version of a simple Mysql Left Join
I have a simple Left query on mysql
SELECT sp. * , p.name, p.date_created
FROM subpages sp
LEFT JOIN pages p ON p.id = sp.page_id
I dont know how to execuite this query from zend framework.
I have a Mapper Page, which access a DbTable page which is…

mrN
- 3,734
- 15
- 58
- 82
2
votes
2 answers
Zend_Db_Select LIKE clause
How can I set this query
SELECT city_id FROM cities WHERE city_name LIKE "%Vicenza%"
using the Zend_Db_Select class?

Egidio Caprino
- 553
- 10
- 18
2
votes
1 answer
stuck with zend_db_table + join
trying to understand of using Zend_Db_Table.
i have a such table:
then i created classes:
class table_1 extends Zend_Db_Table_Abstract
{
protected $_name = 'table_1';
protected $_primary = 't1_id';
protected $_referenceMap = array(
…

Subdigger
- 2,166
- 3
- 20
- 42
2
votes
2 answers
Zend_Db_Select row level security
How could I accomplish row level security using Zend_Db_Select? I can think of a few options, but they don't really seem to fit the pattern quite right.
Let's say I have users, content, and many different ACL levels. Here's one solution I've thought…

Stephen Fuhry
- 12,624
- 6
- 56
- 55