[Resolved] Php & Oracle

liunx

Guest
Hi, I was finally able to load and use the oci modules in PHP5, but now my problem is the syntax. I have a table named test with 2 fields id and name, and the table has 2 records. Now I'm trying to get all of the records from the table but I seem to get only one record. I've tried different functions but I can't seem to do what I want. Check out my code:


echo "<pre>";
$db = "95249";


$oracle_connection = oci_connect("BERNARDO", "BERNARDO", $db);

$stmt = oci_parse($oracle_connection, "SELECT * FROM PRUEBA");
oci_execute($stmt, OCI_DEFAULT);
$or_rs = oci_fetch_row($stmt);
print_r(array_change_key_case($or_rs));

But it only gets one record. I've also tried oci_fetch_array() and oci_fetch_all() but I can't seem to be able to select all records. Any suggestions?oci_execute($stmt, OCI_DEFAULT);
while ($row = oci_fetch_assoc($stmt))
{
print_r($row);
}Dude, I had already tried that. I added more records to the table, so now I have 3 records:

ID NAME
1 Bernardo
2 Benjamin
3 Oscar

Whenever I execute the PHP page, it shows this:

Array ( [ID] => 2 [NAME] => BERNARDO ) Array ( [ID] => 3 [NAME] => BERNARDO ) Array ( [ID] => 4 [NAME] => BERNARDO ) Array ( [ID] => 5 [NAME] => BERNARDO )

This is the exact PHP code:

$db = "95249";
$oracle_connection = oci_connect("BERNARDO", "BERNARDO", $db);

$stmt = oci_parse($oracle_connection, "SELECT * FROM PRUEBA");
oci_execute($stmt, OCI_DEFAULT);
while ($row = oci_fetch_assoc($stmt))
{
print_r($row);
}

I know the connection is working because I use the same parameter that I use with Oracle SQL * Plus, and the query works fine. Please Help!I'm such an ass. I had an error on the php.ini. I discommented the extension=php_oci8.dll, but not the extension=php_oracle.dll. Once I did, everything started working as it should. Thanx anyway for your help.
 
Back
Top