Welcome Guest, Not a member yet? Register   Sign In
SQLite3 + CI 1.7.2
#5

[eluser]wwwald[/eluser]
[quote author="umefarooq" date="1257945319"]Hi try this patch and its working really fine with CI and sqlite3 i tried it no problem at all

http://blog.trevorbramble.com/past/2009/...r_sqlite3/[/quote]

Very very very useful!

I found some problems with this patch, though. I have posted a reply on Trevor's blog, I hope he can give some feedback on it.

The problem is this: there seem to be problems fetching results using Codeigniter's standard database functions like result(), row(), ...
I have a table "registrations" with some records that I'm SELECTing. However, the following code outputs NO results:

Code:
$regs= $this->db->get('registrations');
foreach ($regs->result() as $row) {
   print_r($row);
}

The following does work. It directly uses functions of the underlying PDOStatement object, instead of using CI's database wrapper to get result records:

Code:
$regs= $this->db->get('registrations');
while ($row = $regs->result_id->fetchObject()) {
   print_r($row);
}

The $regs->result_id is the actual PDOStatement object.
I'm not completely sure why the first code sample does not work, but I suspect it has to do with the num_rows() function in sqlite3_result.php. Because of SQLite3 API specifics, it is not possible to retrieve the rowcount. Hence, PDO also cannot know the rowcount, and the num_rows() functions in sqlite3_result.php simply returns 0 in any case.
I think that causes CI database functions like fetch(), result(), row() to return empty arrays instead of the wanted results.

I don't know if this is the expected behaviour of the library... after all, it's a quick adaptation of an existing library, it doesn't claim full functionality and all that.
I can just resort to using PDOStatement's fetchObject() method to make this work, but I was definitely wondering if this is the intended way of working with this library...

Any thoughts of you guys are appreciated, I hope to hear from Trevor himself too.

Thanks a bunch for the help,

wwwald


Messages In This Thread
SQLite3 + CI 1.7.2 - by El Forum - 11-09-2009, 03:48 PM
SQLite3 + CI 1.7.2 - by El Forum - 11-09-2009, 09:52 PM
SQLite3 + CI 1.7.2 - by El Forum - 11-10-2009, 01:39 AM
SQLite3 + CI 1.7.2 - by El Forum - 11-11-2009, 01:15 AM
SQLite3 + CI 1.7.2 - by El Forum - 11-11-2009, 07:44 AM
SQLite3 + CI 1.7.2 - by El Forum - 11-11-2009, 07:56 AM
SQLite3 + CI 1.7.2 - by El Forum - 11-15-2009, 03:04 PM
SQLite3 + CI 1.7.2 - by El Forum - 11-15-2009, 03:55 PM
SQLite3 + CI 1.7.2 - by El Forum - 12-20-2009, 09:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB