Welcome Guest, Not a member yet? Register   Sign In
insert/update_string
#2

[eluser]gtech[/eluser]
$this->db->update_string(); & $this->db->insert_string();

simple returns an SQL query for you to pass to $this->db->query()



eg.. (ripped from documentation)
Code:
...
$data = array('name' => $name, 'email' => $email, 'title' => $title);
$str = $this->db->insert_string('table_name', $data);

$query = $this->db->query($str);

foreach ($query->result() as $row)
{
    echo $row->title;
    echo $row->name;
    echo $row->email;
}

echo 'Total Results: ' . $query->num_rows();
echo $str
...

As a personal preference I prefer the active_record class (see databases documentation)

Code:
$data = array('title' => 'title' , 'name' => 'Name' , 'email' => 'email');
// active record class $this->db->insert
$query = $this->db->insert('table_name', $data);
foreach ($query->result() as $row)
{
    echo $row->title;
    echo $row->name;
    echo $row->email;
}

echo 'Total Results: ' . $query->num_rows();

see docs for how to use $this->db->update();

Link Here For Docs


Messages In This Thread
insert/update_string - by El Forum - 11-06-2007, 02:34 AM
insert/update_string - by El Forum - 11-06-2007, 04:02 AM
insert/update_string - by El Forum - 11-06-2007, 08:13 AM
insert/update_string - by El Forum - 11-06-2007, 08:26 AM
insert/update_string - by El Forum - 11-06-2007, 12:22 PM
insert/update_string - by El Forum - 11-06-2007, 12:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB