26 个回复 | 最后更新于 2015-07-22
回复#20 @lincanbin :
恩,能介绍一下这个函数吗,query语句与数组结合使用?
private function Init($query, $parameters = "") { if (!$this->bConnected) { $this->Connect(); } try { $this->parameters = $parameters; $this->sQuery = $this->pdo->prepare($this->BuildParams($query, $this->parameters)); if (!empty($this->parameters)) { if (array_key_exists(0, $parameters)) { $parametersType = true; array_unshift($this->parameters, ""); unset($this->parameters[0]); } else { $parametersType = false; } foreach ($this->parameters as $column => $value) { $this->sQuery->bindParam($parametersType ? intval($column) : ":" . $column, $this->parameters[$column]); //It would be query after loop end(before 'sQuery->execute()').It is wrong to use $value. } } $this->succes = $this->sQuery->execute(); $this->querycount++; } catch (PDOException $e) { echo $this->ExceptionLog($e->getMessage(), $this->BuildParams($query)); die(); } $this->parameters = array(); }
登录后方可回帖
前者是缓存前缀,防止冲突,后者是主页条目的缓存。