OCI8 driver doesn’t allow multiple queries to be run in single request. |
|||
|---|---|---|---|
| Date: | 11/06/2007 | Severity: | Minor |
| Status: | Resolved | Reporter: | cpm |
| Version: | 1.5.4 | ||
| Keywords: | Libraries, Database Class | ||
Description
If you try to run two different queries against an Oracle database using the OCI8 driver in a single request, the first query is repeated twice.
I think this is because the driver caches the first query’s statement id and holds onto it for the rest of the request. If you stop it from caching the statement id, the second query runs as expected.
Here’s a patch that stops it from caching the statement id:
http://www.chazmeyers.com/code/ci-oci-fix-multiple-queries.patch
Code Sample
class Test extends Controller {
function index()
{
$this->load->database();
$q = $this->db->query("SELECT 'Hello' FROM dual");
foreach( $q->result() as $row ) {
print_r($row); echo "
";
}
$q = $this->db->query("SELECT 'Goodbye' FROM dual");
foreach( $q->result() as $row ) {
print_r($row); echo "
";
}
}
}
Expected Result
stdClass Object ( [‘HELLO’] => Hello )
stdClass Object ( [‘GOODBYE’] => Goodbye )
Actual Result
stdClass Object ( [‘HELLO’] => Hello )
stdClass Object ( [‘HELLO’] => Hello )
Comment on Bug Report
| Posted by: cashattamu on 11 March 2008 10:08am | |
|
|
I’m having this same problem and had to use this patch in 1.5.4 This is still a bug in 1.6.1, could we get this fixed? |
| Posted by: isaacvetter on 3 September 2008 1:22pm | |
|
|
This is still broken and quite frankly is a very serious bug. |
| Posted by: isaacvetter on 3 September 2008 1:22pm | |
|
|
This forum thread nicely describes the problem: |
