Execute a query and return the number of rows affected

@param string $query
@param mixed  ...$data
@return int
@throws QueryException
770818
public function execute($query, ...$data)
    {
        if ($data) {
            $query = $this->merge($query, $data);
        }

        try {
            return $this->pdo->exec($query);
        } catch (PDOException $exception) {
            throw new QueryException($exception, $query);
        }
    }
697433
public function execute($query)
    {
        $this->_queries[] = $query;

        $sql = is_string($query) ? $query : $query->getString();

        $resultSQL = $this->getAdapter()->execute($sql);
        $result = new Result($resultSQL, $this->getAdapter());
        $result->setQuery($query);

        return $result;
    }
376431
public function execute(string $query, array $parameters = []): int
    {
        return $this->statement($query, $parameters)->rowCount();
    }
122149
public function update(array $data): int
    {
        $this->builder->setUpdateData($data);
        $sql = $this->builder->buildSql();
        $this->builder = new QueryBuilder($this->pdo);
        return $this->execSql($sql);
    }
1187544
public function executeQuery($query)
    {
        $results = $this->mysqliRef->query($query);
        if (!$results) {
            $mex = "Mysql error ".$this->mysqliRef->error." on '".$query."''";
            $this->log($mex);
            throw new MysqltcsException($mex);
        }else {
            $this->log($query);
            return $results;
        }
    }
378819
public function insert( $query, array $data = [ ] )
    {
        $id = NULL;

        $statement = $this->database->prepare( $query );

        if ( FALSE === $statement )
        {
            $this->close();

            throw new DatabaseException( 'Failed to create prepared statement.' );
        }

        $result = $statement->execute( $data );

        $this->query = $statement->queryString;

        if ( FALSE !== $result )
        {
            $result = ( int ) $this->database->lastInsertId();
        }

        return $result;
    }
815815
public static function executeNone(string $query): int
  {
    self::logQuery($query);

    return self::$dl->executeNone($query);
  }
108590
private function executeQuery($query, $data = null) {
        $stmt = $this->conn->prepare($query);
        $stmt->execute($data);
        
        return $stmt;
    }
116044
public static function exec($query)
    {
        $ret = false;

        $res = self::query($query);

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

        return $ret;
    }
1128657
public function ExecuteMultiQuery($query)
    {
        $result = $this->db->multi_query($query);
        if ($result)
        {
            while ($this->db->next_result()) {;} //overgo the results!
        }
        if (!$result)
        {
            throw new DBExceptions\DatabaseException('Error in multi query', 101, $query);
        }
    }
355055
public function query ($query, $data = array(), $entity = null)
		{
			if ($this->cache->isCached($query)) {
				return $this->cache->getCachedResult($query);
			} else {
				try {
					$statement = $this->database->prepare((string) $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
					$result = $statement->execute($data);
					$this->lastQuery = $statement->queryString;
					$this->lastStatement = $statement;

					if (! $result) {
						throw new DatabaseException(implode(': ', $statement->errorInfo()) . PHP_EOL . PHP_EOL . $query);
					}

				} catch (PDOException $e) {
					throw new DatabaseException($e->getMessage() . PHP_EOL . PHP_EOL . $query);
				}

				$databaseResult = $this->createResult($statement, $entity);

				if ($query instanceof DatabaseQuery && $databaseResult instanceof DatabaseResult) {
					$this->cache->cacheQuery($query, $databaseResult);
				}

				if ($query instanceof DatabaseQuery) {
					$this->cache->refreshCache($query);
				}

				if ($databaseResult instanceof DatabaseResult) {
					return $databaseResult;

				} else if ($query instanceof DatabaseQuery && $query->getType() == DatabaseQuery::QUERY_TYPE_INSERT) {
					return $this->insertId($query->getTable());

				} else {
					return $databaseResult;
				}
			}
		}
676434
public function exec($query)
    {
        if ($this->isConnected()) {
            try {
                return $this->pdo->exec($query);
            } catch (PDOException $e) {
                throw new \Exception($e->getMessage());
                return false;
            }
        } else {
            return false;
        }
    }
586252
public function query($sql, $data = [])
     {
         $this->_init();

         try {
             $q = $this->db->prepare($sql);
         } catch (PDOException $e) {
             throw new Exception($e->getMessage());
         }

         foreach ($data as $k => $v) {
             $$k = $v;
             $q->bindParam(':' . $k, $$k); # bindParam( ... , PDO::PARAM_INT ...);
         }

         $result = $q->execute();

         if (strpos(trim(strtoupper($sql)), 'SELECT') === 0) {
             $rows = [];
             while($row = $q->fetch()) {
                 $rows[] = $row;
             }
             return $rows;
         }

         return $result;
     }
1084733
public function delete($query, array $data) {
        $stmt = $this->executeQuery($query, $data);
        
        return $stmt->rowCount();       
    }
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;
    }
195105
public function query($query, $retarray=false) {
    $db = $this->opendb();

    $result = mysql_query($query, $db);

    if(!$result) {
      //echo "error=" . mysql_error($db) . "<br>error code=" . mysql_errno($db) . "<br>";
      throw new SqlException($query, $this);
    }

    $this->result = $result;
    
    if($retarray) {
      if(!preg_match("/^(?:select|show)/i", $query)) {
        //echo "NOT SELECT<br>";
        $numrows = mysql_affected_rows($db);
      } else {
        //echo "SELECT: query=$query, result=$result<br>";
        $numrows = mysql_num_rows($result);
      }
      return array($result, $numrows, result=>$result, numrows=>$numrows);
    } else {
      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();
	}