1

I know its not meant to be done, but could someone show me how to run an SQL query from a view.

Cheers

1 Answer 1

1

I assume you mean you want access to your models? You can get the main CodeIgniter object/controller with get_instance(), and then access the model through that:

$ci =& get_instance();

$ci->Model_name->find(...);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that .... Im fairly new to CI ... So i enter that into my view? ... and then replace the 'find' with 'query' ?? could you give me an example of using that to write a query
You replace find with whatever method you've written to perform the query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.