Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel\Core\FuelException [ Error ]: Database results are read-only
  • HarroHarro
    Accepted Answer
    A standard DB result is returned the way the driver returns it, which is an immutable result.

    Fuel's architecture encodes on output, instead of filter and strip on input. If you attempt to send a raw database result directly to a view, the View object will want to encode is, which is not possible since they are immutable. This is causing the exception.

    To prevent it, either use as_array() or as_object() when you run your DB query, or pass the result to the View object using the set_safe() method ( which will disable encoding.

    You should only use that last option if you are ABSOLUTELY sure the information in the database is secure. If it came from user input, it isn't, so using this will open you up for attack. Instead, use as_array() or as_object() on your DB::select().
  • i got it when i use set_safe(), But can u give me example of as_array(), or as_object(), how it can be used.

Howdy, Stranger!

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

In this Discussion