Returns each row as objects in an associative array
@param string $sql
@return array
481564
final public static function findBySql (string $sql) : array
	{
        $dbObject 		= Database::getInstance();
		$resultSet 		= $dbObject->query($sql);
		$objectArray 	= [];
		while ($row = Database::fetchAssoc($resultSet))
		{
			$objectArray[] = static::instantiate($row);
		}
		return $objectArray;
	}
1147663
public function rawQuery(string $sql, array $params=[]): array
  {
    $rows = [];

    # Sanity check
    if (empty($sql)) {
      return $rows;
    }

    # Obtain transaction, unelss already in a transaction
    $autoCommit = $this->beginTransaction();

    # Prepare
    if ($sth = $this->prepare($sql)) {

      # Binds
      foreach ($params as $bind=>$value) {
        $sth->bindValue( ':'.\ltrim($bind,':'), $value);
      }

      # Execute statement
      if ($sth->execute()) {
        $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
      }

      # Close the cursor
      $sth->closeCursor();
    }

    # If we had a loacl transaction, commit it
    if ($autoCommit) $this->commit();

    return $rows;
  }
420754
public function sqlFetch(string $sql, array $params = []): ?array
    {
        return $this->prepare($sql, $params)->fetch(\PDO::FETCH_ASSOC);
    }
394450
public function getObject($sql = null, $parameters = array()) {
		$this->execute($sql, $parameters);
		$result = array();
		while (!!$objects = $this->result->fetchObject()) {
			$result[] = $objects;
			
		}
		return $result;
	}
368018
public function getRow($sql, $params = array())
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetch($this->fetchMode);
    }
433189
public function getRow($sql, array $args = [])
    {
        $query = $this->query($sql, $args);
        if (!$query) {
            return [];
        }
        
        $rs = $query->fetch(\PDO::FETCH_ASSOC);
        return $rs;
    }
421718
protected function query_row_assoc ( $sql )
	{
		list($sql, $args) = $this->sql_args(func_get_args());
		return any_db_query_row_assoc($sql, $args);
	}
659729
protected function queryFetchAll(string $sql): array
    {
        $statement = $this->createQueryStatement($sql);
        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);

        if (!$rows) {
            return [];
        }

        return $rows;
    }
689927
public function fetch_arrays($sql)
    {
        $result = $this->query($sql);

        $data  = [];
        while (true == ($row = mysql_fetch_assoc($result))) {
            $data[] = $row;
        }
        mysql_free_result($result);
        return $data;
    }
1094458
public function replaceSiteDomainInSqlArray(array $sql)
    {
        if (empty($sql)) {
            return [];
        }

        $delimiter = md5(uniqid('delim', true));
        $joined = implode($delimiter, $sql);
        $replaced = $this->replaceSiteDomainInSqlString($joined);

        return explode($delimiter, $replaced);
    }
497795
public function getRow($sql, array $args = [])
    {
        $result = $this->query($sql, $args);
        
        if (!$result) {
            return [];
        }
        
        $row = $result->fetch_row();
        
        return $row;
    }
97730
public function fetch_assoc_list($sql, $assign_by = null)
    {

        if (empty($sql)) return false;

        $result = array();

        // send the query
        $res = $this->query($sql);

        if (empty($res)) return false;

        while (($row = @mysql_fetch_assoc($res)) !== false) {
            if (!empty($assign_by)) {
                $result[$row[$assign_by]] = $row;
            } elseif (!empty($assign_by) && is_array($assign_by)) {
                $key = '';
                // for more complex keys
                foreach ($assign_by as $key_w) {
                    $key = "- $row[$key_w]";
                }
                // removes the first '- '
                $key          = substr($key, 2);
                $result[$key] = $row;
            } else {
                $result[] = $row;
            }
        }

        // free the ressource afterwards
        $this->free($res);

        return $result;
    }
120995
protected function getJoinSql(array $sql): array
    {
        if (empty($this->join)) {
            return $sql;
        }
        foreach ($this->join as $item) {
            [$type, $table, $leftField, $operator, $rightField] = $item;
            $joinType = strtoupper($type) . ' JOIN';
            $table = $this->quoter->quoteName($table);
            if ($leftField instanceof RawExp) {
                $sql[] = sprintf('%s %s ON (%s)', $joinType, $table, $leftField->getValue());
            } else {
                $leftField = $this->quoter->quoteName($leftField);
                $rightField = $this->quoter->quoteName($rightField);
                $sql[] = sprintf('%s %s ON %s %s %s', $joinType, $table, $leftField, $operator, $rightField);
            }
        }

        return $sql;
    }
1264072
protected function query_row ( $sql )
	{
		$sql = $this->sql_printf(func_get_args());
		try 
		{
			$all = $this->conn->query($sql, PDO::FETCH_NUM);
			$row = array();
			foreach ($all as $r) {
				$row = $r;
				break;
			}
		}
		catch (PDOException $e)
		{
			$this->sql_errcheck($sql);
		}
		return $row;
	}
477613
protected function getSelectSql(array $sql): array
    {
        $sql[] = trim('SELECT ' . trim(implode(' ', [
            $this->distinct,
            $this->highPriority,
            $this->straightJoin,
            $this->resultSize,
            $this->bufferResult,
            $this->calcFoundRows,
        ])));

        return $sql;
    }
1343997
public function getOneAll($sql, $params = array(), $column_number = 0)
    {
        $stmt = $this->execute($sql, $params);
        $all  = array();
        while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $all[] = $row[$column_number];
        }

        return $all;
    }
422532
public static function insertBySql($sql)
    {
        if (is_array($sql)) {
            $bind = $sql;
            unset($bind[0]);
            $sql = $sql[0];
        } else {
            $bind = [];
        }

        $model = new static;

        $table = $model->getSource($bind);
        return $model->getConnection($bind)->insertBySql('INSERT' . " INTO [$table] " . $sql, $bind);
    }