Welcome Guest, Not a member yet? Register   Sign In
How do you connect to a database manually?
#1

[eluser]johnnyForums[/eluser]
Can I use CodeIgniter and not us the ActiveRecord connector? I want to use Sqlite and it doesn't work so well with the built in nor the wiki helps for it. I thought I could connect manually but I'm not sure what to do. Do I just create a model as usual but have a php connection statement in there? Can the view still call it?

Thank you.
#2

[eluser]jmadsen[/eluser]
This should get you started;

http://ellislab.com/codeigniter/user-gui...cting.html


Never, never call a model from a view. I kill a kitten every time I hear someone did that.
#3

[eluser]johnnyForums[/eluser]
[quote author="jmadsen" date="1285955816"]This should get you started;

http://ellislab.com/codeigniter/user-gui...cting.html


Never, never call a model from a view. I kill a kitten every time I hear someone did that.[/quote]

Is that not what you call it when you load the model in the view? you "call" it?
#4

[eluser]techgnome[/eluser]
You have three sections: Controller, Model, & View... the code in the VIEW should never call a model... The Controller calls the Model, gets the data from the Model and PASSES it to the View... the view is ignorant of where the data came from. All it knows is that it's been passed a buffet of data.

In your case, your models should be calling the appropriate sqlLite db methods (how ever that's being done) and returns data to the controller. The controller then passes that to the view. Again, the view doesn't care if it came from sqlLite, mySQL, MSSQL, or a text file. It just inserts Tab A into Slot B.

That was the point that jmadsen was trying to make.

Consider this - today you're using SQLLite... let's say next month mySQL becomes an option... wouldn't it be nice to simply replace just the models? If you start putting database calls in your views, then you would have to change all of those too.

-tg
#5

[eluser]johnnyForums[/eluser]
I just misspoke. I meant the controller. Oh well, hindsight is 20/20.




Theme © iAndrew 2016 - Forum software by © MyBB