Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Some sample queries in Codeigniter</p> <pre><code>class Names extends Model { function addRecord($yourname) { $this-&gt;db-&gt;set("name", $yourname); $this-&gt;db-&gt;insert("names"); return $this-&gt;db-&gt;_error_number(); // return the error occurred in last query } function updateRecord($yourname) { $this-&gt;db-&gt;set("name", $yourname); $this-&gt;db-&gt;update("names"); } function deleteRecord($yourname) { $this-&gt;db-&gt;where("name", $yourname); $this-&gt;db-&gt;delete("names"); } function selectRecord($yourname) { $this-&gt;db-&gt;select("name, name_id"); $this-&gt;db-&gt;from("names"); $this-&gt;db-&gt;where("name", $yourname); $query = $this-&gt;db-&gt;get(); return $this-&gt;db-&gt;result(); } function selectAll() { $this-&gt;db-&gt;select("name"); $this-&gt;db-&gt;from("names"); return $this-&gt;db-&gt;get(); } } </code></pre> <p>More information and more ways for CRUD in <a href="http://codeigniter.com/user_guide/database/active_record.html" rel="nofollow noreferrer">codeigniter active record documentation</a> More about error number over <a href="http://codeigniter.com/forums/viewthread/61557/" rel="nofollow noreferrer">here</a></p> <p>A sample controller</p> <pre><code>class names_controller extends Controller { function addPerson() { $this-&gt;load-&gt;Model("Names"); $name = $this-&gt;input-&gt;post("name"); // get the data from a form submit $name = $this-&gt;xss-&gt;clean(); $error = $this-&gt;Names-&gt;addRecord($name); if(!$error) { $results = $this-&gt;Names-&gt;selectAll(); $data['names'] = $results-&gt;result(); $this-&gt;load-&gt;view("show_names", $data); } else { $this-&gt;load-&gt;view("error"); } } } </code></pre> <p>More about controllers over <a href="http://codeigniter.com/user_guide/general/controllers.html" rel="nofollow noreferrer">here</a></p> <p>A sample view - show_names.php</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;Name&lt;/td&gt; &lt;/tr&gt; &lt;?php foreach($names as $row): ?&gt; &lt;tr&gt;&lt;td&gt;&lt;?ph echo $row-&gt;name; ?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;?php endforeach; ?&gt; &lt;/table&gt; </code></pre> <p>More about codeigniter views over <a href="http://codeigniter.com/user_guide/general/views.html" rel="nofollow noreferrer">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload