SQL or PHP
Posted: Tue Dec 11, 2007 7:09 pm
Ok yes, I am using Zend Framework. So my question...
if I use the Zend DB Table class I can build select queries like so:
and then I execute the query and am on my way. Now, here is where my question really is. I could do a simple thing thing like this:
which gets the same results that I need. The problem is that the table may have 30 rows and I only need one column while the first example (using more php than sql) gets it done one way and the second example (using sql more than php) also gets it done (but with 29 extra rows returned).
So what I am wondering is if the extra "mile" to use the Zend DB class to make my select statement is faster than just selecting everything and just using what I need in the PHP code.
I suppose my question really is this: Is going the extra mile using PHP to make my queries as optimal as possible worth it or should I just use MySQL to get everything from maybe a 30 row column and use only 1 of the rows returned in my script? Which is more optimal?
If I am not being clear let me know so I can give more details.
if I use the Zend DB Table class I can build select queries like so:
Code: Select all
$select = $this->THINGY->getAdapter()->select()
->from(
'table',
array(
'one_single_row',
)
);Code: Select all
$select = $this->THINGY->fetchAll();So what I am wondering is if the extra "mile" to use the Zend DB class to make my select statement is faster than just selecting everything and just using what I need in the PHP code.
I suppose my question really is this: Is going the extra mile using PHP to make my queries as optimal as possible worth it or should I just use MySQL to get everything from maybe a 30 row column and use only 1 of the rows returned in my script? Which is more optimal?
If I am not being clear let me know so I can give more details.