Hi there,
I just started off with CI and wanted to play a bit using sqlite. I was very happy to see that CI has scaffolding support so I tried. And bang! an error message - looking through the forums I have seen some people advising to use a ‘normal’ relational database. The point is not that (as I mostly use mysql on production sites) but to be able to use the functionality in CI however one wishes. So I made a fix.
Fixes are for CI version 1.5.2
just unzip the attached file to your CI installation and done.
fixed:
- _list_columns() functions in sqlite_driver - added pragma table_info(tbl_name)
- count_all() function in sqlite_driver - used backticks that sqlite does not like (it seems)
- DB_driver file, modified list_fields() to recognize values from sqlite’s pragma table_info function (above)
As forum wont let me attach php or zip files, here’s the changes:
in system/database/DB_driver.php, in the function list_fields(), modify foreach
foreach($query->result_array() as $row)
{
if (isset($row['COLUMN_NAME']))
{
$retval[] = $row['COLUMN_NAME'];
}
else if(isset($row['name'])) // sqlite
{
$retval[] = $row['name'];
}
else {
$retval[] = current($row);
}
}
in system/database/drivers/sqlite/sqlite_driver.php in function count_all(), modify (remove backticks from this line)
$query = $this->query("SELECT COUNT(*) AS numrows FROM ".$this->dbprefix.$table."");
in system/database/drivers/sqlite/sqlite_driver.php in function _list_columns(), modify:
function _list_columns($table = '')
{
return 'PRAGMA table_info('. $this->_escape_table($table).')';
}
I hope Rick will put this fix into the next version.
Regards,
Csaba
