Showing posts with label Codeigniter. Show all posts
Showing posts with label Codeigniter. Show all posts

Codeigniter with oracle

Now let me show how to make..CI connect with oracle database..
there are some things we need to prepare

  •   make sure our web server already supports connections to Oracle databases by checking through browser.with create a some *.php file with the contents
<?;
phpinfo();
?>
 and you will see a description like in the picture below


if the information is there then there is ready to work with Oracle database.or if not then you need to set up your web server settings .. see how web servers work with the Oracle database this link


Connection Parameters

Not all of the parameters in application/config/database.php are used as one might expect.  Namely, $db[‘default’][‘database’] isn’t used at all.  The value used for $db[‘default’][‘hostname’] depends on whether the Oracle client’s tnsnames.ora file exists and contains information about the database to be used.  If the file exists and is configured for the intended database, this parameter should be set to the symbolic name.  Otherwise, it should be set to a single string of the connection parameters that tnsmames.ora would normally contain.
An example of connection parameters for the latter case:

$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))(CONNECT_DATA=(SID=dbsid)))';
$db['default']['username'] = 'dbuser';
$db['default']['password'] = 'dbpassword';
$db['default']['database'] = ''; // not used by this Oracle driver
$db['default']['dbdriver'] = 'oci8'; 


In this case, the appropriate values need to be set for the HOST, PORT, and SID keywords in the hostname parameter.

Different queries return the same results

If you run two different queries in the same script you can run into the problem, that both queries return the same result.

Example

$this->load->database();
$query1 = $this->db->query("SELECT * FROM table1");
$result1 = $query1->result(); // Returns Value of table 1
$query1->free_result();

$query2 = $this->db->query("SELECT * FROM table2");
$result2 = $query2->result(); // Also returns Value of table 1 

Solution

In file codeigniter/database/driver/oci8/oci8_driver.php you should change the lines

function _set_stmt_id($sql)
    
{
        
if ( ! is_resource($this->stmt_id))
        
{
            $this
->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
        
}
    } 
 
to


function _set_stmt_id($sql)
    
{
        $this
->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
    
} 


happy CI..^_^

    Internal Service Error karena .htaccess, edit aja httpd.conf

    Buka file httpd.conf (ada di folder AppServ\Apache2.2\conf) kemudian cari ”#LoadModule rewrite_module modules/mod_rewrite.so“ hilangkan tanda komentar (“#”) sehingga menjadi LoadModule rewrite_module modules/mod_rewrite.so. Simpan dan restart apachenya. Insya Allah .htaccess akan berjalan dan berfungsi dengan normal. asumsi file .htacces RewriteEngine On RewriteBase / #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] # If we don't have mod_rewrite installed, all 404's # can be sent to index.php, and everything works as normal. # Submitted by: ElliotHaughin ErrorDocument 404 /index.php

    Membuat file. Htaccess.

    Kita perlu membuat sebuah file bernama. Htaccess kemudian simpan ke direktori root instalasi kita. The. Htacces file kita harus menciptakan akan berisi petunjuk yang memungkinkan file dan folder tertentu untuk dapat dilihat pada situs web. Ini juga akan menghapus index.php di URL tujuan apapun. Contoh jika Anda mengakses menyambut Anda tanpa pengendali. Htaccess url harus terlihat seperti ini http://localhost/tutorial/index.php/welcome. Jika file. Htaccess hadir berisi baris kode berikut di bawah ini, Anda sekarang dapat mengakses controller menyambut Anda dengan url ini http://localhost/tutorial/welcome RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]