so i have been having some trouble binding my array parameters to my query string i have try’ed using the default pdo bindParams but i could not seem to get it to work right from within a foreach loop. so i currently tried using str_replace and preg_replace but in both cases the params seem to replace then revert back on the second iteration.
im really lost on what else to try or maybe a different way to go about this task.
public function execute(){
$statement = $this->_statements[$this->_query_count][0];
$params = $this->_statements[$this->_query_count][1];
if(count($params) > 0){
// currently where im trying to replace the found placeholders in the query string
// with the an assoc array that identifies the the placeholder with the value.
foreach($params as $k => $v){
$k = str_replace(':' , '' , $k);
$qs = preg_replace('/\\:['.$k.']+/i' , $v , $statement);
}
var_dump($qs);
//var_dump($transaction->execute());
//$this->_columns_count = $transaction->columnCount();
//$this->_affected_rows = $transaction->rowCount();
}else{
$transaction = $this->_lid->prepare($statement);
$transaction->execute();
$this->_columns_count = $transaction->columnCount();
$this->_affected_rows = $transaction->rowCount();
}
//$this->_statements[$this->_query_count] = $transaction;
//return $this;
}