/** * Execute * * @param string $sql * @throws Exception\InvalidQueryException * @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 Exception\InvalidQueryException($this->resource->error); } $resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource); return $resultPrototype; }
/** * Execute * * @param null|array|Parameters $parameters * @throws Exception\RuntimeException * @return Result */ public function execute($parameters = null) { if (!$this->isPrepared) { $this->prepare(); } if (!$this->parameters instanceof Parameters) { if ($parameters instanceof Parameters) { $this->parameters = $parameters; $parameters = null; } else { $this->parameters = new Parameters(); } } if (is_array($parameters)) { $this->parameters->setFromArray($parameters); } if ($this->parameters->count() > 0) { $this->bindParameters(); } $return = $this->resource->execute(); if ($return === false) { if (in_array($this->resource->errno, array(1060, 1061, 1062))) { throw new Exception\DuplicateException($this->resource->error, $this->resource->errno); } 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; }