Koneksi Oracle dengan CodeIgniter

Karena pagi-pagi gak ada kerjaan dan hanya kelesotan di kasur, maka sebaiknya melakukan sedikit yang berguna dengan memberi sedikit tutorial. Tutorial yang gak berat sih, tapi saya yakin ini bermanfaat.

Saya akan sedikit memberi tips bagaimana koneksi Oracle 10g dengan CodeIgniter 1.7.2 dalam environment XAMPP 1.7.3. Buka folder config pada CodeIgniter lalu cari file database.php dan ini skrip untuk setingan koneksi.

$db['default']['hostname'] = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=orcl)))";
$db['default']['username'] = "semarang";
$db['default']['password'] = "semarang";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";

Eniwei, jangan lupa un-comment driver koneksi oracle di php.ini dengan cara menghilangkan tanda “;” di awal depan karakter driver php_0ci8.dll dan File php.ini bisa anda temukan di, folder php/php.ini

;extension=php_mysqli_mysqlnd.dll
extension=php_mysqli_libmysql.dll
extension=php_oci8.dll
extension=php_pdo.dll
;extension=php_pdo_dblib.dll";

Leave a comment if you wanna something to discuss it :), Happy Weekend all

Advertisements

14 responses to “Koneksi Oracle dengan CodeIgniter

  1. Saya pake CI 1.7.2, oracle 10g XE. Untuk CI nya saya dah setting autoload.php, database.php dan php.ini juga sudah saya setting seperti yang mas sebutkan diatas tapi tetep ga bisa konek, pesannya : “A Database Error Occurred, Unable to connect to your database server using the provided settings.” Dibawah ini settingan database.php saya :

    $active_group = “default”;
    $active_record = TRUE;

    $tnsname = ‘(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 8080))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =XE)))’;
    $db[‘default’][‘hostname’] = $tnsname;
    $db[‘default’][‘username’] = “MAINAPPS”;
    $db[‘default’][‘password’] = “dh”;
    $db[‘default’][‘database’] = “MAINAPPS”;
    $db[‘default’][‘dbdriver’] = “oci8”;
    $db[‘default’][‘dbprefix’] = “”;
    $db[‘default’][‘pconnect’] = TRUE;
    $db[‘default’][‘db_debug’] = TRUE;
    $db[‘default’][‘cache_on’] = FALSE;
    $db[‘default’][‘cachedir’] = “”;
    $db[‘default’][‘char_set’] = “utf8”;
    $db[‘default’][‘dbcollat’] = “utf8_general_ci”;

    Apa ada yang lupa saya setting??? Terima kasih 😀

  2. pakai xampp atau webserver apa?

    kalo saya liat, $db[‘default’][‘database’] = “MAINAPPS” , ini di kosongin ajah karena tns name secara otomatis udah langsung membaca databasenya, tanpa perlu kita set database untuk oracle di database.php

  3. saya coba untuk ngikutin cara diatas,tapi ada eror spt ini :

    A PHP Error was encountered

    Severity: Notice

    Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS – assumed ‘OCI_COMMIT_ON_SUCCESS’

    Filename: database/DB.php

    Line Number: 144

    setting database.php spt ini :
    $db[‘default’][‘hostname’] = ‘(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(Host = 10.2.3.2)(Port = 1521)))(CONNECT_DATA = (SID = dbtprk10)))’;
    $db[‘default’][‘username’] = ‘user’;
    $db[‘default’][‘password’] = ‘pass’;
    $db[‘default’][‘database’] = ”;
    $db[‘default’][‘dbdriver’] = ‘oci8’;
    $db[‘default’][‘dbprefix’] = ”;
    $db[‘default’][‘pconnect’] = TRUE;
    $db[‘default’][‘db_debug’] = TRUE;
    $db[‘default’][‘cache_on’] = FALSE;
    $db[‘default’][‘cachedir’] = ”;
    $db[‘default’][‘char_set’] = ‘utf8’;
    $db[‘default’][‘dbcollat’] = ‘utf8_general_ci’;
    $db[‘default’][‘swap_pre’] = ”;
    $db[‘default’][‘autoinit’] = TRUE;
    $db[‘default’][‘stricton’] = FALSE;

    mohon bantuan untuk menyelesaikan….

  4. mas, saya dapet error kayak gini:
    A Database Error Occurred

    Error Number:

    SELECT * FROM “supplier” WHERE “id_supplier” = ‘sup000043’

    Filename: E:\MyWorks\Web\xampp\htdocs\Ci-TrialError\system\database\DB_driver.php

    Line Number: 330

    pas saya coba query itu dioracle, itu hasilnya emang ngga bisa

    perkiraan saya sih karena kayaknya harusnya select * from supplier bukan “supplier” (pake tanda petik)

    ato gimana ya mas?

  5. config saya:
    $db[‘default’][‘hostname’] = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=orcl)))’;
    $db[‘default’][‘username’] = ‘SiestaMadokaist’;
    $db[‘default’][‘password’] = ‘t’;
    $db[‘default’][‘database’] = ”;
    $db[‘default’][‘dbdriver’] = ‘oci8’;
    $db[‘default’][‘dbprefix’] = ”;
    $db[‘default’][‘pconnect’] = TRUE;
    $db[‘default’][‘db_debug’] = TRUE;
    $db[‘default’][‘cache_on’] = FALSE;
    $db[‘default’][‘cachedir’] = ”;
    $db[‘default’][‘char_set’] = ‘utf8’;
    $db[‘default’][‘dbcollat’] = ‘utf8_general_ci’;
    $db[‘default’][‘swap_pre’] = ”;
    $db[‘default’][‘autoinit’] = TRUE;
    $db[‘default’][‘stricton’] = FALSE;

  6. A PHP Error was encountered

    Severity: Notice

    Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS – assumed ‘OCI_COMMIT_ON_SUCCESS’

    Filename: database/DB.php

    Line Number: 144

    mas koq saya error begistu yah… saya pake CI 2.1.0

  7. ada yang bisa bantu errornya dimana yang ini:
    mysqli::real_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES)
    trims 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s