3
votes

I have the following which works fine as a standard MySQL query:

SELECT 'page' AS result_type,...

However, I need to create this query using active record in the codeigniter framework.

I tried this:

$this->db->select('\'page\' AS result_type');

But that returns an error saying Unknown column ''page'' in 'field list'

I've tried various other similar approaches but they all fail.

Is this even possible in Active record and if so, can you please point me in the right direction??

3

3 Answers

1
votes

Are you sure your table column name is 'page'? Why is it named so? page is not a MySQL reserved word (as per v.5.5.16 - the current one) as far as I know.

Try using the following syntax:

$this->db->select('\'page\' AS `result_type`,... ...');
$query = $this->db->get('your_table');

This post may help you: How to properly use Alias in Codeigniter

1
votes

because your using quotes instead of backtick, quote(') means it is string so try this instead

 $this->db->select('`page` AS result_type');
0
votes

You can try like this

$this->db->select("'page' AS result_type",FALSE);

or this

$this->db->select('\'page\' AS result_type',FALSE);

add FALSE parameter at the end $this->db->select('\'page\' AS result_type', FALSE);