상속: use trait Nette\SmartObject
 /**
  * @param  string  statement
  * @param  array
  * @return ResultSet
  */
 public function queryArgs($statement, array $params)
 {
     $this->connection->connect();
     if ($params) {
         if (!$this->preprocessor) {
             $this->preprocessor = new SqlPreprocessor($this->connection);
         }
         array_unshift($params, $statement);
         list($statement, $params) = $this->preprocessor->process($params);
     }
     try {
         $result = new ResultSet($this->connection, $statement, $params);
     } catch (\PDOException $e) {
         $e->queryString = $statement;
         $this->connection->onQuery($this->connection, $e);
         throw $e;
     }
     $this->connection->onQuery($this->connection, $result);
     return $result;
 }
예제 #2
0
파일: Zabbix.php 프로젝트: jiang51/monda
 static function query($query)
 {
     if (!self::$zq) {
         Monda::init_sql();
     }
     if (!is_array($query)) {
         $args = func_get_args();
     } else {
         $args = $query;
     }
     $psql = new \Nette\Database\SqlPreprocessor(self::$zq->connection);
     list($sql) = $psql->process($args);
     CliDebug::dbg("zquery(\n{$sql}\n)=\n");
     if (Options::get("progress")) {
         CliDebug::progress("Z\r");
     }
     $ret = self::$zq->queryArgs(array_shift($args), $args);
     CliDebug::dbg(sprintf("%d\n", count($ret)));
     self::$lastsql = $sql;
     return $ret;
 }
예제 #3
0
 /**
  * @param  string  statement
  * @param  array
  * @return Statement
  */
 public function queryArgs($statement, $params)
 {
     foreach ($params as $value) {
         if (is_array($value) || is_object($value)) {
             $need = TRUE;
             break;
         }
     }
     if (isset($need) && $this->preprocessor !== NULL) {
         list($statement, $params) = $this->preprocessor->process($statement, $params);
     }
     return $this->prepare($statement)->execute($params);
 }
예제 #4
0
	/**
	 * Generates and executes SQL query.
	 * @param  string  statement
	 * @param  mixed   [parameters, ...]
	 * @return ResultSet
	 */
	public function query($statement)
	{
		$this->connect();

		$args = is_array($statement) ? $statement : func_get_args(); // accepts arrays only internally
		list($statement, $params) = count($args) > 1
			? $this->preprocessor->process($args)
			: array($args[0], array());

		try {
			$result = new ResultSet($this, $statement, $params);
		} catch (\PDOException $e) {
			$e->queryString = $statement;
			$this->onQuery($this, $e);
			throw $e;
		}
		$this->onQuery($this, $result);
		return $result;
	}
예제 #5
0
 /**
  * @return [string, array]
  */
 public function preprocess($sql, ...$params)
 {
     $this->connect();
     return $params ? $this->preprocessor->process(func_get_args()) : [$sql, []];
 }
예제 #6
0
파일: Connection.php 프로젝트: jave007/test
 /**
  * @return [string, array]
  */
 public function preprocess($statement)
 {
     $this->connect();
     return func_num_args() > 1 ? $this->preprocessor->process(func_get_args()) : array($statement, array());
 }