php - How to connect PDO-oci with codeigniter -
here database.php(application/config/database.php)'s code(i modify first half accords server configuration):
$db['default'] = array( 'dsn' => 'oci:dbname = (description = (address_list = (address = (protocol = tcp)(host = server ip)(port = server port)) ) (connect_data = (service_name = project) ) )', 'hostname' => 'server ip', 'username' => 'exampg', 'password' => 'server pw', 'database' => 'project_exampg', 'dbdriver' => 'pdo');
when load database in controller($this->load->database()), meet:
sqlstate[hy000]: pdo_oci_handle_factory: ora-12560: tns:protocol adapter error
how solve problem?
i have test pdo-oci connection these codes follows(it can work):
$tns = "(description = (address_list = (address = (protocol = tcp)(host = server ip)(port = server port)) ) (connect_data = (service_name = project) ))"; $db_username = "exampg"; $db_password = "server pw"; try{ $db = new pdo("oci:dbname=".$tns,$db_username,$db_password); }catch(pdoexception $e){ echo ($e->getmessage()); }
Comments
Post a Comment