Welcome Guest, Not a member yet? Register   Sign In
[TUTORIAL] Changing the database driver(s) without touching the core files
#1

[eluser]xwero[/eluser]
Derek Jones made a great point in this thread :
Quote:if you want legacy MySQL support, you can simply copy the existing MySQL driver to a newly named folder, change the db_set_charset() method to return TRUE, and maintain the legacy driver file.

I put it to the test and copied the database/drivers/mysql directory with the files under the name my_mysql, silly i know but i was thinking about extending libraries and to keep a consistency for custom files i used the my_ prefix.

I changed the filenames to
- my_mysql_driver.php
- my_mysql_forge.php
- my_mysql_result.php
- my_mysql_utility.php

and the appropriate classes to
- CI_DB_my_mysql_driver
- CI_DB_my_mysql_forge
- CI_DB_my_mysql_result
- CI_DB_my_mysql_utility

I changed the config/database.php file
Code:
$db['default']['dbdriver'] = "my_mysql";

And everything worked automagically.

Have fun tweaking the database driver classes!
#2

[eluser]wiredesignz[/eluser]
Very cool xwero, Nice work. Smile




Theme © iAndrew 2016 - Forum software by © MyBB