Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with output_filter
  • Hi,

    I have this problem. I enabled output_filtering, like this:

    config.php
    [code]
    'output_filter'  => array('Security::htmlentities'),

    'whitelisted_classes' => array(
                'stdClass',
                'Fuel\\Core\\Response',
                'Fuel\\Core\\View',
                'Fuel\\Core\\Presenter',
                'Fuel\\Core\\Validation',
                'Closure',
            ),
    [/code]

    But now I get errors when loading query data...

    [code]
    $query = \DB::select()
                ->from('test')
                ->where('user_id', '=', $user_id)
                ->order_by('date', 'DESC')
                ->as_object()
                ->execute();

            return $query;
    [/code]

    I get this error: Database results are read-only
  • When I do this:

    $query = \DB::select()
                ->from('test')
                ->where('user_id', '=', $user_id)
                ->order_by('date', 'DESC')
                ->execute()
                ->as_array();

    it seems to work...  But I want to use objects...
  • The DB driver does:

                if ($as_object === false)
                {
                    $result = $result->fetchAll(\PDO::FETCH_ASSOC);
                }
                elseif (is_string($as_object))
                {
                    $result = $result->fetchAll(\PDO::FETCH_CLASS, $as_object);
                }
                else
                {
                    $result = $result->fetchAll(\PDO::FETCH_CLASS, 'stdClass');
                }

                // Return an iterator of results
                return new \Database_Result_Cached($result, $sql, $as_object);

    so ->as_object() should return a collection of stdClass objects.

    It is Database_Result_Cached which is read-only, and should be excluded in the whitelist, not stdClass.
  • Ok... I will try. I use mysqli btw
  • mmm doesn't seem to work... if I whitelist Database_Result_Cached...

    What I noticed is when I select the current() record, it works...
  • Or is it only possible to pass arrays to my view?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion