Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error 22001 When object->save();
  • Hi everyone, i have a problem with my code and not see the fail.

    I have this code

    protected function addImage($id = null, $file = null){
            $imagen = Model_Imagen::find_by_id($id);

                $imagen = Model_Imagen::forge();

            $archivo = $file;
            $file = File::open_file($archivo,"r");
            $file_store = file_get_contents($archivo);
            $mimetype = getimageSize($archivo)['mime'];

            $imagen =  Model_Imagen::forge(
                'imagen' => $file_store,
                'mimetype' =>  $mimetype,


            $id_imagen = $imagen->id;
            return $id_imagen;
    And get this error when i want  save:

    Fuel\Core\Database_Exception [ 22001 ]:
    COREPATH/classes/database/pdo/connection.php @ line 253

    248                            {
    249                                $error_code = 0;
    250                            }
    251                        }
    253                        throw new \Database_Exception($e->getMessage().' with query: "'.$sql.'"', $error_code, $e);
    254                    }
    255                }
    257                // no more attempts left, bail out
    258                else



  • I found the fail, but only can save 1 time; but when i try to save the 2nd time, error become again.
  • HarroHarro
    Accepted Answer
    It would have helped to post the error message as well, saved me looking it up.

    PDO Exception SQLSTATE[22001] means "String data, right truncated". In other words, your database is running in strict mode, and you are trying to save more data than can fit in a column.

    This can only mean you don't validate your data before it goes into to the database. Add validation rules to the fields in your model to prevent that.
  • Sorry, but this is all info of the error i have.

    I want save image an blob field on DB. And this error appear when i create a new image record.
    Why this is? i need an specific or special config for use this data type.
  • Hi everyone
    Thanks Harro, i found the solucions, i set blob field as LONGBLOB ;)
  • If you develop in development mode, it should display the error in the exception. It should also be present in the app log.

    How exactly is your column defined, and how big is this file you are trying to store? A column of type BLOB is on 64KB big. See

    You might have to switch to MEDIUMBLOB or LONGBLOB.

Howdy, Stranger!

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

In this Discussion