php - Changing table name in Zend_db_select -



php - Changing table name in Zend_db_select -

select sum(table.columnthatchanges) 'count', table.b 'param' table table.c = 4 , table.b = 'something' , table.date between '2014-01-01 00:00:00' , '2014-06-30 00:00:00'

i have sql query generate in php. want phone call query quite few times slight change; changing columnthatchanges every request.

what better/fastest way this? utilize str_replace? phone call entire string everytime? utilize type of class generates sql statement?

i'm generating way zend:

$somequery = $this->db->select(); $somequery->from(table, array('sum(table.columnthatchanges) count', 'table.b param')) ->where('c = ?', $variable) ->where('b = ?', $variable2) ->where('date > ?', $start_date) ->where('date < ?', $end_date);

i haven't had much success changing columnthatchanges part of query, maybe i'm doing wrong?

if can utilize pdo extension, there prepared statements this

<?php $stmt = $dbh->prepare("insert registry (name, value) values (:name, :value)"); $stmt->bindparam(':name', $name); $stmt->bindparam(':value', $value); // insert 1 row $name = 'one'; $value = 1; $stmt->execute(); // insert row different values $name = 'two'; $value = 2; $stmt->execute();

in zend framework can achieved using zend_db_statement

upd if want alter columns, stated here, can utilize columns method or sec argument from method;

$select = $db->select() ->from(array('p' => 'products'), 'product_id') ->columns('product_name');

then if want alter anything, need preserve $select object.

upd-2 bill karwin has provided improve reply lastly version of question. please @ it.

php mysql sql zend-framework

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -