Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use this as an example</p> <pre><code>class Crud extends Model { // selecting records by specifying the column field function select() { // use $this-&gt;db-&gt;select('*') if you want to select all the records $this-&gt;db-&gt;select('title, content, date'); // use $this-&gt;db-&gt;where('id', 1) if you want to specify what row to be fetched $q = $this-&gt;db-&gt;get('mytable'); // to get the result $data = array(); // for me its better to check if there are records that are fetched if($q-&gt;num_rows() &gt; 0) { // by doing this it means you are returning array of records foreach($q-&gt;result_array() as $row) { $data[] = $row; } // if your expecting only one record will be fetched from the table // use $row = $q-&gt;row(); // then return $row; } return $data; } // to add record function add() { $data = array( 'title' =&gt; 'My title' , 'name' =&gt; 'My Name' , 'date' =&gt; 'My date' ); $this-&gt;db-&gt;insert('mytable', $data); } // to update record function update() { $data = array( 'title' =&gt; $title, 'name' =&gt; $name, 'date' =&gt; $date ); $this-&gt;db-&gt;where('id', 1); $this-&gt;db-&gt;update('mytable', $data); } // to delete a record function delete() { $this-&gt;db-&gt;where('id', 1); $this-&gt;db-&gt;delete('mytable'); } } </code></pre> <p>Some of this are from codeigniter <a href="http://codeigniter.com/user_guide/database/active_record.html" rel="nofollow noreferrer">userguide</a>.</p> <p>To view the records,</p> <p>If return data is array of records, </p> <pre><code> foreach($data as $row) { echo $row['title'] . "&lt;br /&gt;"; } </code></pre> <p>If the return data is an object (by using <code>$q-&gt;row</code>),</p> <pre><code> echo $data-&gt;title; </code></pre> <p>This is just a few examples or CRUD in Codeigniter. Visit the codeigniter <a href="http://codeigniter.com/user_guide/database/active_record.html" rel="nofollow noreferrer">userguide</a>.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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