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

[eluser]Computerzworld[/eluser]
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.
#2

[eluser]Unknown[/eluser]
$this->db->query("INSERT INTO {$tablename} ({$field_name}) VALUES ({$value})");
#3

[eluser]dmorin[/eluser]
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:

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




Theme © iAndrew 2016 - Forum software by © MyBB