Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
PDO connection, list_columns() returned data
  • I'm using FuelPHP 1.8 and MySQL 5.5

    When using the PDO database connection and calling the list_columns() function which uses the statement 'DESCRIBE table', the data expected is not returned. When using the MySQLi driver, the list_columns() functions uses the statement 'SHOW FULL COLUMNS FROM table' which does return the correct data.

    I believe this is due to MySQL's DESCRIBE function used in list_columns().
    DESCRIBE is a shortcut for SHOW COLUMNS. In order to get the 'comments' data for the columns, you must use the FULL keyword.

    Is there a reason that the list_columns() function for the PDO driver uses DESCRIBE or can this be something an issue/ticket can change?

    If this isn't possible to change, what's the best way to get all the column info using the PDO driver?
    Possibly as simple as this: 
    $result = \DB::query('SHOW FULL COLUMNS FROM table', \DB::SELECT)->as_object()->execute();

    Thanks
  • HarroHarro
    Accepted Answer
    The current DB layer was ported from Kohana some three years ago, and is driver specific, instead of platform specific.

    So instead of having a MySQL, MSSQL, DB2 etc driver (that may or may not use PDO underneath), we have specific drivers directly linked to their PHP API's. In this respect, PDO is not linked to a platform, but is a generic driver. Because it doesn't know it talks to MySQL, it can't use MySQL specific SQL, it has to use ANSI SQL.

    This issue is solved in Fuel v2, which has a new database layer with platform specific drivers. If you only need a DB layer (and no Model_Crud or Orm), you can use it today in your existing application. See https://github.com/fuelphp/database
  • Thanks for the explanation. 
    If I understand correctly, by using the new DB layer, I lose the ORM functionality? If that's the case, I'll have to use my custom function that does what I need for this application because I rely on ORM heavily.

    Thanks
  • Yes, the v2 ORM isn't finished yet.

Howdy, Stranger!

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

In this Discussion