Welcome Guest, Not a member yet? Register   Sign In
CI session to db and replaving DB
#1

[eluser]zcourts[/eluser]
I'm new to CI and I've spent today going through the docs and playing with some examples.
Time's a bit tight on this one but CI was recommended by a friend, its been great getting off the ground so fast but now I need to make it play nice with an existing system.

The current system uses a No sql db for storing session data,page cache and all other persisted data, i.e. useername,pass etc.

Can someone point me in the right direction to replacing or extending the Session,Cache and DB functionalities or extending them to use existing php libraries that are currently being used. The docs says the DB classes can't be replaced but the post at http://ellislab.com/forums/viewthread/158955/ says otherwise... That post is dated 2009, is it still valid?

The DB and session are the most important, DB of highest importance, there's no chance of using mysql and I don't want to dive in and hack my way through the core...
any/all pointers are much appreciated.
#2

[eluser]WanWizard[/eluser]
There are basically two options:
- go into system/database/drivers, and make your own driver for your nosql database (requires all methods to be present)
- make a library to interact with your nosql.

For most, there are PHP libraries available, it shouldn't be difficult to turn these into a CI library.

Then copy the session library from system/libraries to application/libraries, and replace all $this->db functionality by calls to $this->yourlibrary.
#3

[eluser]zcourts[/eluser]
Thank you for the reply.
Second option of making a library sounds nicer since it doesn't require the old sql methods to be present (as far as I understand?)...

For the session's that seems very practical as well...
Will CI then automatically use my two libraries as long as I call load("mylibrary")?
More importantly does it not load the default session and DB libraries or is there a config
option I need to tinker with to make it auto load mine and ignore CI's default?
#4

[eluser]WanWizard[/eluser]
If you copy the system/libraries/session.php to application/libraries/session.php, $this->load->library('session'); will load your version from application and ignore the one in system.

If you then modify the copied version to use your storage backend, you keep all functionality in place, which means any CI application that uses sessions can use your session library without code modifications, and you could decide to switch to DB sessions later without modifications to your code.

It is up to you if you autoload your storage backend library (if you use it in sessions, it probably wise since you need it at every page request). Autoload it, and your session library, in the config's autoload section.
#5

[eluser]zcourts[/eluser]
Got it, replaced the session class and got it working. Haven't tried saving session data to db yet but I also got the DB replaced. Found a little trick to even have CI automatically replace it's $db instance with mine so I still get to use $this->db->mymethod(); etc

Thanks for the replies, they've been helpful




Theme © iAndrew 2016 - Forum software by © MyBB