Part of the EllisLab Network
   
 
sqlite scaffolding issues and fixes for CI 1.5.2
Posted: 28 February 2007 08:28 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  3
Joined  02-28-2007

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

 Signature 

You become what you think about.

Profile
 
 
Posted: 26 October 2007 03:36 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  2
Joined  10-26-2007

hye,
thanks for fixes
Best regards

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64453 Total Logged-in Users: 22
Total Topics: 80957 Total Anonymous Users: 0
Total Replies: 435678 Total Guests: 170
Total Posts: 516635    
Members ( View Memberlist )