Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
oil refine migrate error in Ubuntu 12.04 and about mysql strict mode.
  • Hi, Approximately for two weeks I am trying to use fuelphp. But I am faced problem with mysql syntax and couldn't solve it in one way or another. Error is: Error - 2012-09-21 08:16:55 --> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL, `name` varchar NOT NULL, `migration` varchar DEFAULT '' NOT NULL ) D' at line 2 [ CREATE TABLE IF NOT EXISTS `migration` ( `type` varchar NOT NULL, `name` varchar NOT NULL, `migration` varchar DEFAULT '' NOT NULL ) DEFAULT CHARACTER SET utf8; ] in /home/musty/httpdocs/fuel/core/classes/database/mysqli/connection.php on line 243 For example I say ": "oil refine migrate", constantly I get the following error. ... syntax to use near 'NOT NULL, `name` varchar NOT NULL, `migration` varchar DEFAULT '' NOT NULL


    Somebody's on the forum says that problem is come from mysql strict mod. On the other hand, in mysql variable nothing is identified. Do you think problem is stem from Ubuntu 12.04 ? System: Ubuntu 12.04 Apache : 2.2.22 PHP Version : 5.3.10-1ubuntu3.3 MySQL : 5.5.24 Thank you in advance (I'm sorry for my english :))
  • problem is not mysql strict mode.
    fuel/core/classes/dbutil.php.
    (line: 304)
    $attr = array_change_key_case($attr, CASE_UPPER);
    it should return "CONSTRAINT" (i ---> I ) but it return to me "CONSTRAiNT" (i ---> i )
    workaround :
    add function:
    public static function array_change_key_case_unicode(
    $arr, $c = CASE_LOWER) {
    $c = ($c == CASE_LOWER) ? MB_CASE_LOWER : MB_CASE_UPPER;
    foreach ($arr as $k => $v) {
    $ret[mb_convert_case($k, $c, "UTF-8")] = $v;
    }
    return $ret;
    }
    and
    $attr = array_change_key_case($attr, CASE_UPPER); (line: 304)
    instead of
    $attr = static::array_change_key_case_unicode($attr, CASE_UPPER); Thanks.
  • That should not be necessary. The keys in that array are (or should be) all SQL keywords, and should therefore be ASCII only. If the array_change_key_case() doesn't work, that means the source value wasn't ASCII, so you might have to check your input file.
  • You're missing the constraint in your definition. So VARCHAR misses it's length. Like "`name` varchar(10) NOT NULL," ...
  • I'm Sorry, I do not understand.
    migration table has been created by the fuel core?
  • How did you generate? If you do
    php oil generate migration create_users name:text email:string password:string
    
    instead of
    php oil generate migration create_users name:text email:string[50] password:string[125]
    
    then the resulting migration is missing the required string length. Can you post the generated file on http://scrp.at and post the link here?
  • Quite possible. In strict mode all "not null" columns are required to have a default value. Which you can't specify on the Oil commandline.

Howdy, Stranger!

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

In this Discussion