Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions user_guide/database/active_record.html
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,37 @@ <h2>$this->db->insert();</h2>
<br /><br />
// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')</code>

<p>The first parameter will contain the table name, the second is an associative array of values.</p>

<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>



<h2>$this->db->insert_batch();</h2>
<p>Generates an insert string based on the data you supply, and runs the query. You can pass a
<strong>multidimensional array</strong> to the function:</p>

<code>
$data = array(<br/>
&nbsp;&nbsp;&nbsp;array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
&nbsp;&nbsp;&nbsp;),<br />
&nbsp;&nbsp;&nbsp;array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'Another title' ,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'Another Name' ,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'Another date'<br />
&nbsp;&nbsp;&nbsp;)<br/>
);<br />
<br />
$this->db->update_batch('mytable', $data);
<br /><br />
// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')</code>

<p>The first parameter will contain the table name, the second is a multidimensional associative array of values.</p>

<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>



<h2>$this->db->set();</h2>
<p>This function enables you to set values for <dfn>inserts</dfn> or <dfn>updates</dfn>.</p>
Expand Down