Variable/arguments to Models ? |
[eluser]Fab75[/eluser]
Hi, i'm new to MVC, I don't understand why we only can pass variable at the loading of the model and not each time we call a function of the models.. I must miss something! I run a cron via a controller, and have a loop which needs to run many times the same sql queries, with each time a "WHERE id=" whic is different.. So each time, i need to pass a variable... I can't find what's the best technique to do this, i'm for sure not on the right track.. the only solution i have now is to put my queries in the controller, but it's not DRY like as i use those queries many times on my website.. If someone can help me, i'll be joyful! Maybe the best & good solution, is to make a bigger whole query, and then sort it via an array ?
[eluser]Dam1an[/eluser]
You can pass ay number of argument you want into a function in a model Code: $this->load->model('my_model');
[eluser]Fab75[/eluser]
Hmm dont seems to work Lookin there ( http://ellislab.com/forums/viewthread/125263/ ) or there (http://ellislab.com/forums/viewthread/115681/) looks like it can't be done this way ? Of course the method you provide would be perfect to me ^^
[eluser]Dam1an[/eluser]
ok, think we need to see some code? Also in those 2 threads, they say you can pass methods to functions in your model :-S
[eluser]Fab75[/eluser]
Thank you so much for trying to help me out As i was trying to clean a little up my code before sending, i found an error with my get_instance(); !! And it works Anyway, thanks you for coming to help me, it's very nice!! I'm beginning with php and CI, do you know why half of my errors dosesn't disaply any errors, just a blank page ? It's harder to find the errors, and i didn't move anything about error reporting |
Welcome Guest, Not a member yet? Register Sign In |