Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's actually a much easier way to do what you want to do using the ActiveRecord class that CodeIgniter includes which will allow you to just return an array of results. Here's the <a href="http://codeigniter.com/user_guide/database/active_record.html#select" rel="nofollow">documentation</a>.</p> <p>Your model would become:</p> <pre><code>$this-&gt;db-&gt;where('last_name','Hart'); $result = $this-&gt;db-&gt;get('users'); return $result-&gt;result_array(); </code></pre> <p>You may also have to setup your database in <code>application/config/database.php</code>, and also load the database class in <code>application/config/autoload.php</code>:</p> <pre><code>$autoload['libraries'] = array('database'); </code></pre> <p>To display this information, using the MVC pattern properly your controller should pass the information it gets from the model to a view. To do this generally you do this:</p> <pre><code>$data['myinfo'] = $this-&gt;test-&gt;getInfo(); $this-&gt;load-&gt;view('test_view',$data); </code></pre> <p>Then you have to create a view like so in <code>applications/views/test_view.php</code>:</p> <pre><code>&lt;h1&gt;Some HTML goes here&lt;/h1&gt; &lt;?php foreach($myinfo as $row) { echo $row['field']; } ?&gt; &lt;p&gt;Some more HTML goes here&lt;/p&gt; </code></pre> <p>I suggest you read the <a href="http://codeigniter.com/user_guide/" rel="nofollow">CodeIgniter User Guide</a> before diving into creating an application as CodeIgniter includes libraries that greatly simplify and speed up the whole process.</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. 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