Beispiel #1
0
 /**
  * Executes a query to the database.
  *
  * - query($sql)
  * - query($sql, $limit)
  * - query($sql, $offset, $limit)
  * - query($sql, $binds)
  * - query($sql, $binds, $limit)
  * - query($sql, $binds, $offset, $limit)
  *
  * @param string $sql Sql query.
  * @param array $binds,... Array of binds.
  * @param int $offset,... Offset of first row returned.
  * @param int $limit,... Limit rows count.
  *
  * @return Result
  * @throws \Bitrix\Main\Db\SqlQueryException
  */
 public function query($sql)
 {
     list($sql, $binds, $offset, $limit) = self::parseQueryFunctionArgs(func_get_args());
     if ($limit > 0) {
         $sql = $this->getSqlHelper()->getTopSql($sql, $limit, $offset);
     }
     $trackerQuery = null;
     if ($this->queryExecutingEnabled) {
         $connection = Main\Application::getInstance()->getConnectionPool()->getSlaveConnection($sql);
         if ($connection === null) {
             $connection = $this;
         }
         if ($this->trackSql) {
             $trackerQuery = $this->sqlTracker->getNewTrackerQuery();
             $trackerQuery->setNode($connection->getNodeId());
         }
         $result = $connection->queryInternal($sql, $binds, $trackerQuery);
     } else {
         if ($this->disabledQueryExecutingDump === null) {
             $this->disabledQueryExecutingDump = array();
         }
         $this->disabledQueryExecutingDump[] = $sql;
         $result = true;
     }
     return $this->createResult($result, $trackerQuery);
 }
Beispiel #2
0
 /**
  * Executes a query without returning result, i.e. INSERT, UPDATE, DELETE
  *
  * @param string $sql
  * @param array $arBinds
  */
 public function queryExecute($sql, array $arBinds = null)
 {
     $trackerQuery = null;
     if ($this->trackSql) {
         $trackerQuery = $this->sqlTracker->getNewTrackerQuery();
     }
     $this->queryInternal($sql, $arBinds, 0, 0, $trackerQuery);
 }