Welcome Guest, Not a member yet? Register   Sign In
CI Compatible query syntax

Hello, I am having one insert query as,

insert into TABLENAME values(value1,value2,value3,value4,value5).
What is the exact compatible query in CI for this? I don't require the field names in the query.

Thanks in advance.

$this->db->query("INSERT INTO {$tablename} ({$field_name}) VALUES ({$value})");

I know this is an older post, but in case anyone comes across this in the future, I wanted to comment that the above query does NOT escape the text you pass in so it's your responsibility to do so. Instead, use either active record or escape it as the user guide demonstrates:

$sql = "INSERT INTO mytable (title, name)
        VALUES (".$this->db->escape($title).", ".$this->db->escape($name).")";
echo $this->db->affected_rows();

Theme © iAndrew 2016 - Forum software by © MyBB