예제 #1
0
파일: Mysql.php 프로젝트: tillk/vufind
 /**
  * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo||\mysqli|\PDO $driver
  * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
  * @return $this
  */
 public function setDriver($driver)
 {
     // handle Zend\Db drivers
     if ($driver instanceof Mysqli\Mysqli || $driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Mysql' || $driver instanceof \mysqli || $driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql') {
         $this->resource = $driver;
         return $this;
     }
     throw new Exception\InvalidArgumentException('$driver must be a Mysqli or Mysql PDO Zend\\Db\\Adapter\\Driver, Mysqli instance or MySQL PDO instance');
 }
예제 #2
0
파일: Statement.php 프로젝트: Rovak/zf2
 /**
  * Execute
  *
  * @param  ParameterContainer $parameters
  * @return mixed
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     if ($this->parameterContainer->count() > 0) {
         $this->bindParametersFromContainer();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->resource->execute() === false) {
         throw new Exception\RuntimeException($this->resource->error);
     }
     if ($this->bufferResults === true) {
         $this->resource->store_result();
         $this->isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     $result = $this->driver->createResult($this->resource, $buffered);
     return $result;
 }
예제 #3
0
 /**
  * Execute
  * 
  * @param  string $sql
  * @return Result 
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     $resultResource = $this->resource->query($sql);
     // if the returnValue is something other than a mysqli_result, bypass wrapping it
     if ($resultResource === false) {
         throw new \Zend\Db\Adapter\Exception\InvalidQueryException($this->resource->error);
     }
     $resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
     return $resultPrototype;
 }
예제 #4
0
파일: Statement.php 프로젝트: rikaix/zf2
 /**
  * Execute
  * 
  * @param  ParameterContainer $parameters
  * @return mixed 
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     $parameters = $parameters ?: $this->parameterContainer;
     if ($parameters != null) {
         if (is_array($parameters)) {
             $parameters = new ParameterContainer($parameters);
         }
         if (!$parameters instanceof ParameterContainer) {
             throw new \InvalidArgumentException('ParameterContainer expected');
         }
         $this->bindParametersFromContainer($parameters);
     }
     if ($this->resource->execute() === false) {
         throw new \RuntimeException($this->resource->error);
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }