« Return to Thread: Zend_Db_Select Question
I’m trying to invoke the AND NOT
clause like so.
WHERE label = ‘N1 SL’ AND NOT
shift_id = 5
I could just write a select statement,
however I like the programmatic approach
of Zend_Db_Select as well as the
flexibility.
From: David Muir [mailto:david@...]
Sent: Sunday, May 17, 2009 9:22 PM
To: Brandon Peacey
Cc: fw-core@...
Subject: Re: [fw-core]
Zend_Db_Select Question
Won't this do?
$select->Where('shift_id != ?',
$shiftID);
David
Brandon Peacey wrote:
Hello, I have a question about Zend_Db_Select:
My question, does Zend_Db_Select have an option to
where you can add an AND NOT clause like so.
SELECT COUNT(shift_id) as total FROM location_shifts
WHERE location_id = '1' AND label = 'N1 SL' AND NOT shift_id = '5'
I currently have the select query setup like this.
$select =
$this->select();
$select->from($this->_name,
array('total' =>
new Zend_Db_Expr('COUNT(shift_id)')))
->where('label = ?', $label);
if ($locationID)
$select->where('location_id = ?',
$locationID);
if ($shiftID)
$select->Where('shift_id = ?',
$shiftID);
$select->limit(1);
And this is the generated
output
SELECT COUNT(shift_id) AS `total` FROM
`location_shifts` WHERE (label = 'N1 SL') AND (location_id = 1) AND (shift_id =
5) LIMIT 1
Thank you for your time in advanced
f
« Return to Thread: Zend_Db_Select Question
| Free embeddable forum powered by Nabble | Forum Help |