Welcome Guest, Not a member yet? Register   Sign In
How to tweak system/database/DB_cache.php
#1

Hello,

I need to make few changes in write() method but I do not want to change it in system folder because of possible updates etc. Is there any way I can tweak the function without changing the main file in system folder?
Reply
#2

Depending on the file you should be able to extend it and make your changes with the MY_ prefix.

MY_Router
MY_Input
etc;

If file is in ./system/core it goes in ./application/core
If file is in ./system/libraries it goes in ./application/libraries
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

File is in ./system/database/
Reply
#4

From what the documentation says is that you cannot extend the database files.

You can create your own database drivers but not sure where the code is that
you need to edit and change.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 02-19-2018, 10:48 AM by neuron.)

(02-19-2018, 06:47 AM)DeiForm Wrote: File is in ./system/database/

I found and impelemented following solution here https://github.com/bcit-ci/CodeIgniter/w...se-Drivers:
in application/core/MY_DB_mysqli_driver.php:
PHP Code:
<?php  if (! defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_DB_mysqli_driver extends CI_DB_mysqli_driver 

{
    final public function 
__construct($params) {

        
parent::__construct($params);

    }

and in application/core/MY_Loader.php:

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class 
MY_Loader extends CI_Loader {



 
 public function database($params ''$return FALSE$active_record NULL)

 
 {

// Grab the super object

 
   $CI =& get_instance();



// Do we even need to load the database class?

 
   if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))

 
   {

 
     return FALSE;

 
   }



 
   require_once(BASEPATH.'database/DB.php');



 
   $db DB($params$active_record);



// Load extended DB driver

 
   $custom_db_driver config_item('subclass_prefix').'DB_'.$db->dbdriver.'_driver';

 
   $custom_db_driver_file APPPATH.'core/'.$custom_db_driver.'.php';



 
   if (file_exists($custom_db_driver_file))

 
   {

 
     require_once($custom_db_driver_file);



 
     $db = new $custom_db_driver(get_object_vars($db));

 
   }



// Return DB instance

 
   if ($return === TRUE)

 
   {

 
     return $db;

 
   }

// Initialize the db variable. Needed to prevent reference errors with some configurations

 
   $CI->db '';

 
   $CI->db =& $db;

 
 }

}



/* End of file MY_Loader.php */

/* Location: ./application/core/MY_Loader.php */ 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB