/** * Executes a prepared sql statement. Also if limit is set to true is used * to return limited set of records * Return true on success * @param string $sqlId - sql to pe executed * @param array $params - array of values which are passed as parameters * to the sql * @param resource $sql - pointer to the constructed sql * @param boolean $limit - if set to true we use a pagging mechanizm * @param integer $nrows - number of rows to return * @param integer $offset - the offset from which the nrows should be returned * @return boolean */ protected function execute($sqlId, $params, &$sql, $limit = false, $nrows = -1, $offset = -1, $order = '', $sort = '') { if ($this->dbtype == 'mongodb') { return jqGridDB::mongoexecute($sqlId, $params, $sql, $limit, $nrows = 0, $offset, $order, $sort, $this->mongofields); } if ($this->dbtype == 'array') { if ($params && is_array($params)) { foreach ($params as $k => $v) { $params[$k] = "'" . $v . "'"; } } } $this->select = $sqlId; if ($limit) { $this->select = jqGridDB::limit($this->select, $this->dbtype, $nrows, $offset, $order, $sort); } if ($this->debug) { $this->logQuery($this->select, $params); } try { $sql = $this->parseSql($this->select, $params); $ret = true; if ($sql) { $ret = jqGridDB::execute($sql, $params); } //DB2 if (!$ret) { $this->errorMessage = jqGridDB::errorMessage($this->pdo); throw new Exception($this->errorMessage); } } catch (Exception $e) { if (!$this->errorMessage) { $this->errorMessage = $e->getMessage(); } if ($this->showError) { $this->sendErrorHeader(); } else { echo $this->errorMessage; } return false; } return true; }