ImportModel::query PHP Method

query() public method

Run a query, replacing database prefixes.
public query ( string $Sql, array $Parameters = null ) : Gdn_DataSet
$Sql string The sql to execute. - :_z will be replaced by the import prefix. - :_ will be replaced by the database prefix.
$Parameters array PDO parameters to pass to the query.
return Gdn_DataSet
    public function query($Sql, $Parameters = null)
    {
        $Db = Gdn::database();
        // Replace db prefixes.
        $Sql = str_replace(array(':_z', ':_'), array($Db->DatabasePrefix . self::TABLE_PREFIX, $Db->DatabasePrefix), $Sql);
        // Figure out the type of the type of the query.
        if (stringBeginsWith($Sql, 'select')) {
            $Type = 'select';
        } elseif (stringBeginsWith($Sql, 'truncate')) {
            $Type = 'truncate';
        } elseif (stringBeginsWith($Sql, 'insert')) {
            $Type = 'insert';
        } elseif (stringBeginsWith($Sql, 'update')) {
            $Type = 'update';
        } elseif (stringBeginsWith($Sql, 'delete')) {
            $Type = 'delete';
        } else {
            $Type = 'select';
        }
        // Execute the query.
        if (is_array($Parameters)) {
            $this->SQL->namedParameters($Parameters);
        }
        $Result = $this->SQL->query($Sql, $Type);
        //$this->Timer->Split('Sql: '. str_replace("\n", "\n     ", $Sql));
        return $Result;
    }