Welcome Guest, Not a member yet? Register   Sign In
using active record
#1

[eluser]ann91[/eluser]
Hello everyone...
i have a question
when we use the active record class, should we use "return"

like this
Code:
return $this->db->insert('mytable', $data);

or
Code:
$sql = "INSERT INTO ". $this->table ." (comment_id,name,url,comment) VALUES ('null','". $data["name"] ."','". $data["url"] ."','". $data["comment"] ."')";
        return $this->db->query( $sql );

given the differences both of them..

thanks before
#2

[eluser]InsiteFX[/eluser]
Hi ann91,

The first one should be fine, all it will return is the $sql.

InsiteFX
#3

[eluser]JoostV[/eluser]
You could also return the insert ID, which is more useful info than the SQL

Code:
public function insert ($data){
    $this->db->insert('mytable', $data);
    return $this->db->insert_id();
}
#4

[eluser]ann91[/eluser]
Hello InsiteFX, ok i'll try it...thank you..

JovostV: that's it oke..thank you....




Theme © iAndrew 2016 - Forum software by © MyBB