Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil Refine migrate not working as expected
  • Hello, I am following the tutorial of Phil and when I reached the part of issuing the command below php oil refine migrate but unfortunately I am receiving this error message:
    invalid data source name in COREPATH/classes/database/pdo/connection.php
    I am using windows 7, uniformserver as wamp stack.
    I am using development environment in the bootstrap.
    username and password is ok, rather than using mysql driver I am using PDO, for me to use other database later either SQL Server or Postgres. please help and big thanks for you and to the team of FuelPHP developer
    God bless merdjpatts
  • The error seems pretty clear to me: your PDO database definition (dsn) is incorrect, or oil is not using the correct database environment, and is therefore loading the wrong definition.
  • hello Wanwizard, thanks for quick reply. What I did is, i downloaded the sample of Phil S (part-two of his fuelphp tutorial ) from Github. and I cannot make it work. what else should I do to make it work? sample source code: in my bootstrap.php Fuel::$env = (isset($_SERVER) ? $_SERVER : Fuel::PRODUCTION); **********************************************************************
    in my app/config/db.php
    <?php
    /**
    * Base Database Config.
    *
    * See the individual environment DB configs for specific config information.
    */ return array(
    'active' => 'default', /**
    * Base config, just need to set the DSN, username and password in env. config.
    */
    'default' => array(
    'type' => 'pdo',
    'connection' => array(
    'persistent' => false,
    ),
    'identifier' => '`',
    'table_prefix' => '',
    'charset' => 'utf8',
    'caching' => false,
    'profiling' => false,
    ), 'redis' => array(
    'default' => array(
    'hostname' => '127.0.0.1',
    'port' => 6379,
    )
    ), ); ********************************************************************** in my app/config/config.php 'index_file' => '', 'whitelisted_classes' => array(
    'Fuel\\Core\\Response',
    'Fuel\\Core\\View',
    'Fuel\\Core\\ViewModel',
    'Fuel\Core\Validation',
    'Closure',
    ) 'packages' => array(
    'auth', 'orm',
    ),
    *******************************************
    in my app/config/production/db.php
    <?php
    /**
    * The production database settings.
    */ return array(
    'default' => array(
    'connection' => array(
    'dsn' => 'mysql:host=localhost;dbname=blog',
    'username' => 'root',
    'password' => 'root',
    ),
    ),
    ); can you help me please? thanks God bless
  • Does a database named 'blog' exist?
  • Yes I have the blog database, actually the application I am testing is from Phil himself, which is found in this link below.
    http://net.tutsplus.com/tutorials/php/build-an-admin-panel-with-the-fuel-php-framework/ and the source of this is found in this link https://github.com/philsturgeon/fuelphp-gettingstarted php.exe is already in the windows environment path, oil is working but when I issue the following command php oil refine migrate, I am receiving the error message which I posted previously Your help is highly appreciated Wanwizard
  • I observed that only in console that it encounters a problem, when I try to go the controller such as [url=http://localhost/phil/blog,]http://localhost/phil/blog,[/url] it shows an understandable error because I don't have yet a table named posts. I am frozen in this part because I want to use oil during development. again big big thanks for your help
  • Not sure, but things to check - does your database have a prefix? I ran into problems when I made my site live because it prefixed my database name and my mysql username with my (hosting) username, which I didn't realize until after the fact. If that's not the case, not sure, maybe change localhost to 127.0.0.1 if you are using at home. I'm not familiar with the server you are using so don't know if there is anything weird about it that could cause this.
  • Hello Element13, I did that, changing from localhost to 127.0.0.1, but still not working. no prefix in the database only named as 'blog'. I am downloaded the sample of Phil which is found in the github which i stated the link. Just like my previous posts, I can connect to the database in fact when I tried to go to admin controller it is looking for admin table which is fine because I didn't create it yet. But, doing the oil thing 'php oil refine migrate' it is showing an error. I will try other WAMP stack, maybe it will help. but, then hope someone could pin point this issue to me for me to move on. thanks and best regards
  • The only other thing I can think of is that the commandline uses a different Fuel environment from your webserver. Have you checked http://docs.fuelphp.com/installation/troubleshooting.html#/oil_db_error ?
  • Hello To All: I changed the webserver from uniform to easyphp,unfortunately still not working. downloaded a fresh copy of fuelphp from the site, put php.exe in environment variable of windows 7. this is the code from fuelphp
    *****************************************
    app/config/development/db.php <?php
    /**
    * The production database settings.
    */ return array(
    'default' => array(
    'connection' => array(
    'dsn' => 'mysql:host=127.0.0.1;dbname=blog',
    'username' => 'root',
    'password' => '',
    ),
    ),
    ); *********************************************
    app/config/config.php 'index_file' => '', 'packages' => array(
    'auth',
    'orm',
    ),
    ************************************
    app/config/db.php
    <?php
    /**
    * Base Database Config.
    *
    * See the individual environment DB configs for specific config information.
    */ return array(
    'active' => 'default', /**
    * Base config, just need to set the DSN, username and password in env. config.
    */
    'default' => array(
    'type' => 'pdo',
    'connection' => array(
    'persistent' => false,
    ),
    'identifier' => '`',
    'table_prefix' => '',
    'charset' => 'utf8',
    'caching' => false,
    'profiling' => false,
    ), 'redis' => array(
    'default' => array(
    'hostname' => '127.0.0.1',
    'port' => 6379,
    )
    ), );
    what else should I do to make it work? phpinfo says that pdo is installed. Could anyone email me please a working copy of Phil part 2 of his tutorial? really, tomorrow is another day and it will be third day cracking this issue. btw, I tried stationwagon using both server (uniform and easyphp) it works wonderful, but when it comes to to console for php oil refine migrate then the headache starts.
    thanks for help update: I tried to use xampp, and gotcha! it is working fine. I don't know if this is the problem.
    What I simply I did is downloaded and installed xampp and downloaded the fuelphp v1.1. at first it did work, restarted my pc and everything went fine. Strange but true, now it is working great! Again thanks to you guys for your help, fuelphp rocks! God bless
  • Try copying app/config/development/db.php to app/config/production/db.php. If that solves the problem, you're sure that oil takes the wrong environment settings.
  • Hello WanWizard, I did what you recommend to copy the app/config/development/db.php to app/config/production/db.php. Have you checked my bootstrap? It's all the default settings, except for the Fuel:PRODUCTION, where is this 'php oil refine migrate' error coming from? I want to use the oil for my development, I want to stick with it, because it makes me a purist fuelphp developer. Please wanwizard, help, thanks
  • You don't have multiple versions of PHP installed? If you type 'php -v' on the commandline, do you get the expected version?
  • hello WanWizard, this is what I got when I typed in the console D:\ep3581\www\sw>php -v
    PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)
    Copyright (c) 1997-2011 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies It's PHP 5.3.8 (cli) What else? See I downloaded StationWagon from the sample found in this site.
    It works great, able to connect, but when it comes to php oil refine migrate the same issue is appearing. I dont have this issue in the old version, but here am I paralyzed with v1.1. big thanks, highly appreciate your help...
  • I'm out of ideas. Over to Phil.
  • Hey if you still want a working example of the tutorial I can email you one, let me know. As for your error, no idea. Here is my development db config file that works for me (fuel/app/config/development) (obviously I changed the password and username, but you get the idea), maybe something got changed when you set it up?
    <?php
    /**
     * The development database settings.
     */
    
    return array(
     'default' => array(
      'connection'  => array(
       'dsn'        => 'mysql:host=localhost;dbname=db_name',
       'username'   => 'root',
       'password'   => 'root',
      ),
     ),
    );
    

    Doubt it's affecting your issue, but as a heads up when I went through the tutorial there was a problem with my mySQL database being in strict mode, and I had to change that for part of the tutorial to work. Although now that I think about it I actually think it may not have been the problem and it ended up being something else, something with creating the user and the hash syntax wasn't right, maybe I made a typo, I can't remember. But if you do get a weird error at some point about invalid syntax, that might help. EDIT: just went back and checked, definitely was a problem with db being in strict mode. again, not the issue you are on now but a heads up
  • Without having seen the code yet: the biggest no in strict mode is defining a column as 'text' (or similar), allow null values, but don't supply a default value. Given the fact that this is a blog, this might well be the case. You could check that in the migrations 'create_table' step. Although that should display a different error than a complaint about the dsn...
  • David Wilkins wrote on Friday 16th of December 2011:
    Hey if you still want a working example of the tutorial I can email you one, let me know. As for your error, no idea. Here is my development db config file that works for me (fuel/app/config/development) (obviously I changed the password and username, but you get the idea), maybe something got changed when you set it up?
    <?php
    /**
     * The development database settings.
     */
    
    return array(
     'default' => array(
      'connection'  => array(
       'dsn'        => 'mysql:host=localhost;dbname=db_name',
       'username'   => 'root',
       'password'   => 'root',
      ),
     ),
    );
    

    Doubt it's affecting your issue, but as a heads up when I went through the tutorial there was a problem with my mySQL database being in strict mode, and I had to change that for part of the tutorial to work. Although now that I think about it I actually think it may not have been the problem and it ended up being something else, something with creating the user and the hash syntax wasn't right, maybe I made a typo, I can't remember. But if you do get a weird error at some point about invalid syntax, that might help. EDIT: just went back and checked, definitely was a problem with db being in strict mode. again, not the issue you are on now but a heads up

    I did all the above now, what else need to be done still it's a problem. At the tutorial site, I even asked Phil about it and he told me to use the latest in which I did, in fact I started from the beginning. using different wamp stack to be sure, but no avail. I want to learn v1.1, most specially connection using PDO, for I look forward to using different databases as per company requirements. @element13, kindly send the source to my email account please if it is ok with you. merdjpattugalan at yahoo . com thanks to all for help, I don't want to lose hope, still waiting for your answer guys. again big thanks to all fuelphp community
  • Hello To All: After changing the wamp stack from uniformserver, easyphp to xampp things went well as expected, now oil refine migrate did work well.
    although I faced another issue such as error below: D:\xampp\htdocs\fp>php oil console
    Fuel 1.1 - PHP 5.3.5 (cli) (???) [WINNT]
    >>> Auth::create_user('admin', 'password', 'phil@example.com', 100);
    Warning - Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\fp\fuel\core\classes\cli.php:127) in COREPATH/classes/cookie.php on line 95 when I try to rerun the command it says other thing such as:
    >>> Auth::Create_user('admin', 'password', 'phil@example.com', 100);
    Error - Email address already exists in PKGPATH/auth/classes/auth/login/simpleauth.php on line 212 again hellllpppp. God bless
  • I don't think this is an issue. The Auth::create_user() method is built for use in a web application, not to be used on the commandline. Your second error indicates it has done it's thing... It could be dealt with by adding checks to every statement that could produce output to see if you're in CLI mode, but that would make the code a lot slower, while most of it will never be called from the commandline.
  • Harro Verton wrote on Saturday 17th of December 2011:
    I don't think this is an issue. The Auth::create_user() method is built for use in a web application, not to be used on the commandline. Your second error indicates it has done it's thing... It could be dealt with by adding checks to every statement that could produce output to see if you're in CLI mode, but that would make the code a lot slower, while most of it will never be called from the commandline.

    Auth::Create_user in command-line which I saw from Phil works well except for the errors I stated. After trying to add duplicate usernames/email addresses, I came to realize that Auth::Create_user and throw exception when duplicates accounts entered, so I ignore completely this error. Now, I am following the tutorial (Phil's part two tutorial) still error are appearing such as logout not working for banned accounts, but, I am trying to have an hands-on on it so to analyze how the app works. Again, following up the app is great, it would be greater for me if someone could provide the source of the app itself, as Element13 asked me he could. again big big big thanks to you WanWizard and to the community.
  • Are you referring to https://github.com/philsturgeon/fuelphp-gettingstarted? Was that not mentioned in the tutorial? You'll need a git client to install it locally, as it uses submodules to fetch all FuelPHP components. Alternatively, just download it, and update the components by hand...
  • Yes that's the one, I will try to download and play with it. thanks a lot wanWizard
  • Hi all,
    I had the same problem using uniformserver/winXP, trying to play with fuelphp v1.1, after digging through the settings I found that uniform has a file php-cli.ini where it loads some extensions. Adding "extension=php_pdo_mysql.dll" there solved the problem for me.
  • Hello Noodle, let me try what you posted. Because I want to use uniformserver rather than xampp. After changing to xampp actually, things went smoothly.
    thanks and Best Regards

Howdy, Stranger!

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

In this Discussion