Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
1.1 and Database Configs
  • 1.) config/db.php type is set to 'mysql', and config/development/db.php says the same. I'm getting a "No database selected error. If I change config/db.php type to 'pdo' then it works. 2.) I'm getting an odd period (.) escaping in the query methods for no reason I can think of. "SELECT * WHERE filename='something'.'csv' LIMIT 1" 3.) What is the recommended means of handling multiple database connections? Should I specify in the execute($name) method, or should I switch databases thru the config Config::set('db.active', 'something_new')?
  • Ia had the same problem as you swt83. In Db config file, you didn't set the database name. PDO read from connection.dsn, but Mysql and Mysqli read from connection.database config.
     'default' => array(
      'type'        => 'pdo',
      'connection'  => array(
       'persistent' => false,
       'database' => 'fueltest'
      ),
      'identifier'   => '`',
      'table_prefix' => '',
      'charset'      => 'utf8',
      'caching'      => false,
      'profiling'    => false,
     ),
    
    
  • 1. Is your php installation compiled with mysql support (or are the modules present)? 2. What is the exact statement? 3. That depends. For occasional use, I use the execute() parameter. If I need it throughout a class (or method), I fetch an instance using Database_Connection::instance('config.name'). Changing "db.active" doesn't do anything anymore once the default instance is created, it is cached and reused.
  • 1.) Yes, everything worked fine in version 1.01. 2.) \DB::insert('imports', array(
    'import_id' => $import_id,
    'filename' => $file
    ))->execute(); results in a syntax error caused by a random period in the SQL query, where I find this: `my_file_name`.`csv` It shouldn't be breaking out the period, it should just be `my_file_name.csv` Never seen this before.
  • I can reproduce it. If it worked in 1.0.1, it's a regression error somewhere. Can you file a report about this bug on http://github.com/fuel/core/issues so it can be picked up?
  • I am to report the config issue w/ PDO vs. MySQL?
  • Looked at this again. This can never have worked. The insert() method requires a table name and optionally an array with column names. See http://fuelphp.com/dev-docs/classes/database/db.html#/method_insert. It does not accept key=>value pairs. Now it takes your values to be the column names, and sees the dot as the tablename separator. The correct syntax is:
    $values = array(
        'import_id' => $import_id,
        'filename' => $file
    );
    
    $result = \DB::insert('imports', array_keys($values))->values($values)->execute();
    
    // or
    
    $result = \DB::insert('imports')->set($values)->execute();
    
    

    Afaik this has always been the case.

Howdy, Stranger!

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

In this Discussion