/** * Public method: * Excecutes a query and returns true on success or false. * this->exec( $array:array ):Boolean * @Param array If present, it should contain all replacements for prepared query * @Return Boolean true if query has been done without errors, false otherwise */ function execute($array = array()) { if (count($this->__boundParams) > 0) { $array =& $this->__boundParams; } $__query = $this->__query; if (count($array) > 0) { foreach ($array as $k => $v) { if (!is_int($k) || substr($k, 0, 1) === ':') { if (!isset($tempf)) { $tempf = $tempr = array(); } array_push($tempf, $k); array_push($tempr, $this->__pdo->quote($v)); } else { $params = $this->prepareInput($array); //escape % by making it %% $__query = str_replace('%', '%%', $__query); //replace ? with %s $__query = str_replace('?', '%s', $__query); //add $query to the beginning of the array array_unshift($params, $__query); if (!($__query = @call_user_func_array('sprintf', $params))) { throw new Exception('Could not insert parameters into query string. The number of ?s might not match the number of parameters.'); } // $__query = preg_replace("/(\?)/e", '$array[$k++];', $__query); break; } } if (isset($tempf)) { $__query = str_replace($tempf, $tempr, $__query); } } $log = $this->__pdo->logging; if ($log) { $start = microtime(true); } $this->__result = $this->__uquery($__query); if ($log) { $time = microtime(true) - $start; $this->__pdo->logQuery($__query, $time); } if (is_null($this->__result)) { $keyvars = false; } else { $keyvars = true; } $this->__boundParams = array(); return $keyvars; }