Vamsi Krishna B
Vamsi Krishna B

Reputation: 11500

displaying escaped data [codeigniter]

I am saving the the values in db using $this->db->escape();

$this->db->set('last_name',$this->db->escape($lastname1));

it is adding single quotes, but I don't want to display single in views..is there any built in way to do this ?

Upvotes: 0

Views: 647

Answers (2)

Lukas Knuth
Lukas Knuth

Reputation: 25755

I don't know which class you are using because the MySQLI Class from PHP doesn't have any 'escape()'-Function.

But the common way to escape insert-query's to your Database is using a Prepared Statement.

As i see from the Documentation, there is no real Prepared Statement in this Framework. But, i found this:

$this->db->escape() This function determines the data type so that it can escape only string data. It also automatically adds single quotes around the data so you don't have to:

You should check the Documentation.

Upvotes: 0

Femi
Femi

Reputation: 64710

If the single quotes are showing then you are probably escaping things twice. I've used escape without doubling up on the single quotes. If you look at http://www.codeignitor.com/user_guide/database/active_record.html, you'll see that set automatically escapes by default.

set() will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.

So you don't need to call escape and you should be fine.

Upvotes: 1

Related Questions