Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Oracle -- ocidriver conn_id is boolean
#1

[eluser]regal2157[/eluser]
Hey guys,

Just trying to do a SIMPLE connection, and query. But when I run the query, I get a few errors because $conn_id is a boolean, and not a resource. I'll list the errors shown first, then my settings. I have tried something from the Oracle Known Issues which isn't related to my problem, and of course - no dice.

ERRORS:
Quote:A PHP Error was encountered

Severity: Warning

Message: ociparse() expects parameter 1 to be resource, boolean given

Filename: oci8/oci8_driver.php

Line Number: 186
A PHP Error was encountered

Severity: Warning

Message: ocisetprefetch() expects parameter 1 to be resource, null given

Filename: oci8/oci8_driver.php

Line Number: 171
A PHP Error was encountered

Severity: Warning

Message: ocifetchinto() expects parameter 1 to be resource, null given

Filename: oci8/oci8_result.php

Line Number: 155

A PHP Error was encountered

Severity: Warning

Message: ocifetchinto() expects parameter 1 to be resource, null given

Filename: oci8/oci8_result.php

Line Number: 155

A var dump of the query variable returns this: object(CI_DB_oci8_result)#15 (11) { ["stmt_id"]=> NULL ["curs_id"]=> NULL ["limit_used"]=> NULL ["conn_id"]=> bool(false) ["result_id"]=> NULL ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(0) ["row_data"]=> NULL }. Not sure if that would help.

My settings:
database.php
Code:
$db['abc']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=sid)))';
$db['abc']['username'] = 'user';
$db['abc']['password'] = 'pass';
$db['abc']['database'] = '';
$db['abc']['dbdriver'] = 'oci8';

controller (It's just temp here.. will eventually be moved to a respective model)
Code:
public function test()
{
    $this->load->database();
    $q = $this->db->query("SELECT FIELD FROM TABLE");
    var_dump($q);
    foreach($q->result() as $row)
    {
        echo $row->FIELD;
    }
}
#2

[eluser]regal2157[/eluser]
Just a small update.. I did convert it over to a model, but I still am getting the same errors. (warnings)
#3

[eluser]regal2157[/eluser]
Problem solved. I was connecting to the wrong host (dang multiple servers..).
Solved it quickly using the oci_ functions... haha :/
#4

[eluser]Kamikaze™[/eluser]
Great, but.. Please, Can you explain more about your solution? Because I have the same problem but I can´t solve it since 2 days ago..
#5

[eluser]regal2157[/eluser]
What I did was just used the PHP standard way to connect and query the database and error out if there was an error.

http://php.net/manual/en/oci8.examples.php

This allowed me to see I had invalid credentials, which made me realize I was pointing to the wrong server here.
#6

[eluser]Kamikaze™[/eluser]
Thaks so much, apparently that is the solution, unfortunently 80% of my queries are made and I can´t change them again....
#7

[eluser]regal2157[/eluser]
I just used those functions to see what error was thrown. I then altered the CI settings (for me it was the database config file) and then was able to use the CI database functions again.
#8

[eluser]Kamikaze™[/eluser]
I Assumed this was wrong:
$db['abc']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=sid)))';
$db['abc']['username'] = 'user';
$db['abc']['password'] = 'pass';
$db['abc']['database'] = '';
$db['abc']['dbdriver'] = 'oci8';

But, Which are the correct settings? Please, help me one more time.... please, please...

This is in my tnsnames.ora:
GOBERNAC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = kamikaze-PC)(PORT = 1521))
)
(CONNECT_DATA =
(SID = nf1)
(SERVER = DEDICATED)
)
)
#9

[eluser]regal2157[/eluser]
Do you get the same error when you set the host name to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=kamikaze-PC)(PORT=1521))(CONNECT_DATA=(SID = nf1)(SERVER = DEDICATED)))

Edited it to look like mine. Not sure if you need the Dedicated part. I know you have to leave database empty in the config files.
#10

[eluser]Kamikaze™[/eluser]
GREAT....!!! Problem solved.... Thank you.... This forum has no star or thanks button for you....but thanks.... Then I had strange problems with oci.dll, I downloaded oci.dll for win32 and I put it in system32 and then It connected without problems...

But, no query can run now through CI, even $this->db->get('cargo'); This is the dummy error message

A Database Error Occurred
Error Number:
SELECT * FROM "cargo"
Filename: C:\Archivos de programa\xampp\apache\htdocs\nf1\system\database\DB_driver.php
Line Number: 330


Then when I run the query in a Query Manager I must to write select * from "myschema"."cargo".
Did you have a similar problem?
Is there a way in CI to add the schema name in the queries?




Theme © iAndrew 2016 - Forum software by © MyBB