Executes a query that returns 1 and only 1 row with 1 column.
Throws an exception if the query selects none, 2 or more rows.

@param string $query The SQL statement.

@return mixed The selected row.
553619
public static function executeSingleton1(string $query)
  {
    self::logQuery($query);

    return self::$dl->executeSingleton1($query);
  }
499093
public function runCount($query)
	{
		if (isset($this->stored_query_totals[md5(serialize($query))])) {
			return $this->stored_query_totals[md5(serialize($query))];
		}
		
		$query['terms'] = trim($query['terms']);
		if (isset($query['numericFilters'])) {
			$query['numericFilters'] = implode(',', $query['numericFilters']);
		}
		if (isset($query['facets'])) {
			$query['facets'] = implode(',', $query['facets']);
		}
		
		try {
			return array_get($this->getIndex()->search(array_get($query, 'terms'), array_get($query, 'query')), 'nbHits');
		} catch (\Exception $e) {
			return 0;
		}
	}
1372688
public function query( $query ) {
		if ( ! $this->ready ) {
			if ( isset( $this->check_current_query ) ) {
				// This property was introduced in WP 4.2
				$this->check_current_query = true;
			}
			return false;
		}

		if ( $this->show_errors ) {
			$this->hide_errors();
		}

		$result = parent::query( $query );

		if ( ! SAVEQUERIES ) {
			return $result;
		}

		$i = $this->num_queries - 1;
		$this->queries[ $i ]['trace'] = new QM_Backtrace( array(
			'ignore_frames' => 1,
		) );

		if ( ! isset( $this->queries[ $i ][3] ) ) {
			$this->queries[ $i ][3] = $this->time_start;
		}

		if ( $this->last_error ) {
			$code = 'qmdb';
			if ( $this->use_mysqli ) {
				if ( $this->dbh instanceof mysqli ) {
					$code = mysqli_errno( $this->dbh );
				}
			} else {
				if ( is_resource( $this->dbh ) ) {
					// Please do not report this code as a PHP 7 incompatibility. Observe the surrounding logic.
					// @codingStandardsIgnoreLine
					$code = mysql_errno( $this->dbh );
				}
			}
			$this->queries[ $i ]['result'] = new WP_Error( $code, $this->last_error );
		} else {
			$this->queries[ $i ]['result'] = $result;
		}

		return $result;
	}
698129
public function doQueryOne($query, $data = null)
	{
		// Prepare and execute the entered query
		$prepQuery = parent::prepare($query);
		$prepQuery->execute($data);
		
		// Since this function is only to return one row, only return the first row
		return $prepQuery->fetch();
	}
376431
public function execute(string $query, array $parameters = []): int
    {
        return $this->statement($query, $parameters)->rowCount();
    }
1277561
public function exec($query)
    {
        $stmt = $this->getWye()->makeStatement($query, []);

        $stmt->execute();

        return $stmt->rowCount() !== null ? $stmt->rowCount() : 0;
    }
699765
public function executeRawQuery($query)
    {
        $resultSet = null;
        if($this->odbAdapter) {
            if(!empty($query)) {
                $resultSet = $this->getDbAdapter()->query($query, DbAdapter::QUERY_MODE_EXECUTE);

            }
        }


        return $resultSet;
    }
619195
public function row($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC)
    {
        $query = trim($query);
        if (empty($query)) {
            $query = $this->build();
            if (!$params) {
                $params = $this->getBindValues();
            }
        }

        $this->resetAll();
        $this->lastSql = $query;

        $this->execute($query, $params);
        return $this->sQuery->fetch($fetchmode);
    }
1044041
protected function sendQuery(string $query)
    {
        if (self::$monitorQueries) {
            self::$queriesCount++;
        }
        $result = $this->link->query($query);
        if ($result === false) {
            throw new SqlException(
                'SQL-error [' . $this->link->errno . ']: ' . $this->link->error . "\nSQL-query: $query",
                $this->link->errno
            );
        }

        return $result === true ? $result : new Query\Result($result);
    }
940666
protected function execute($query)
    {
        $query->execute($this->bindings);
        
        $this->bindings = [];
        $this->wheres   = [];

        return $query;
    }
961702
function executeNonQuery($query) {

        try {
            $connection = $this->getConnection();

            if (!mysql_query($query, $connection)) {
                mysql_close($connection);
                throw new \Exception("SQL Error: " . mysql_error());
            }

            mysql_close($connection);
        } catch (\Exception $pEx) {
            throw new \Exception("Fallo al ejecutar la query: " . $query . $pEx->getMessage());
        }
    }
1334384
public static function getRow($query)
    {
        $ret = null;

        $res = self::query($query);
        if ($res) {
            if ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret = $row;
            }
            self::free($res);
        }

        return $ret;
    }
1343319
private function _mysql_query($query) {

        // call "mysqli_query"
        $result = mysqli_query($this->link, $query);

        // stop if there was an error
        if (!$result) throw new Exception($this->_mysql_error());

        // return the result if query was successful
        return $result;

    }
967137
public function execute($query = '')
    {
        if (\is_string($query) && $query !== '') {
            $this->currentQuery = $query;
        } elseif ($query instanceof Query) {
            $this->currentQuery = $query->___build();
        } elseif ($this->preparedQuery instanceof Query) {
            $this->currentQuery = $this->preparedQuery->___build();
        }

        if ($this->currentQuery == '') {
            $this->setError(AbstractMySQL::E_NO_SQL, __CLASS__);
            return null;
        }

        $startTime = $this->getMicrotime();
        if (\preg_match('/^CALL/mi', $this->currentQuery)) {
            $this->currentLink->multi_query($this->currentQuery);
            $result = $this->currentLink->store_result();
        } else {
            $result = $this->currentLink->query($this->currentQuery);
        }
        $queryTime = \round($this->getMicrotime() - $startTime, 4);
        $this->sqlQueries[] = ['query' => $this->currentQuery, 'queryTime' => $queryTime];

        if ($this->logHandler !== null) {
            $this->logHandler->logInfo($this->currentQuery, __CLASS__);
        }
        if (!$result && !\preg_match('/^CALL/mi', $this->currentQuery)) {
            $this->setError(AbstractMySQL::E_ENGINE_ERROR, __CLASS__);
        }

        if ($result instanceof \mysqli_result) {
            $ret = [];
            $this->rowCount = $result->num_rows;
            for ($i = 0; $i < $this->rowCount; $i++) {
                $ret[$i] = $result->fetch_assoc();
            }
            $result->close();
            if ($this->currentLink->more_results()) {
                while ($this->currentLink->next_result()) {
                    $result = $this->currentLink->store_result();
                    if ($result instanceof \mysqli_result) {
                        $result->close();
                    }
                }
            }
        } else {
            $this->rowCount = $this->currentLink->affected_rows;
            $ret = \preg_match('/^insert/mi', $this->currentQuery)
                ? $this->currentLink->insert_id
                : $this->rowCount;
        }
        if ($this->showQuery === true) {
            $fetchTime = \round($this->getMicrotime() - $startTime, 4);
            $queryText = \sprintf(
                '<b>Query %s:</b> %s; <b>[Q: %ss, F: %ss]</b><hr />',
                \count($this->sqlQueries),
                $this->currentQuery,
                $queryTime,
                $fetchTime
            );
            echo filter_var($queryText, FILTER_DEFAULT);
        }
        $this->currentQuery = '';

        return $ret;
    }
1130453
public function select($query, $bindings = array())
	{
		return $this->run($query, $bindings, function($me, $query, $bindings)
		{
			if ($me->pretending()) return array();

			// For select statements, we'll simply execute the query and return an array
			// of the database result set. Each element in the array will be a single
			// row from the database table, and will either be an array or objects.
			$statement = $me->getReadPdo()->prepare($query);

			$statement->execute($me->prepareBindings($bindings));

			return $statement->fetchAll($me->getFetchMode());
		});
	}
589397
public function execute($query) {
		$query = $query->compile();
		return $this->driver->query($query->sql(), $query->params());
	}
203015
public function get_column($query, $params = []) {
		$statement = $this->get_statement($query, $params);
		$statement->execute();
		$result = $statement->fetch_assoc();

		$col = [];
		foreach ($result as $row) {
			$col[] = array_shift($row);
		}

		return $col;
	}