Reputation: 125
In my controller I have:
$query = $this->db->query("select * from table");
I want to have a file myquery.sql
in which the only contents of that file are:
select * from table
And so I can do something like:
$query = $this->db->query(myquery.sql);
What is the right syntax to do this?
Upvotes: 3
Views: 117
Reputation: 6217
You should be able to achieve that using:
$query = $this->db->query(file_get_contents('myquery.sql'));
Read more about file_get_contents.
You might need to use the correct path to myquery.sql
, but that's the basic idea.
Upvotes: 2