title: how to post restfull api to database via codeigniter with explode function?
body: <p>rest api request,
  type:post,
  request body:</p>
  <pre><code>{&quot;data&quot;:&quot;albert amstrong,18838327&quot;}
  </code></pre>
  <p>If you see, i want to separate json object by &quot;,&quot; and post to columns in my database...</p>
  <p>my database name is data</p>
  <p>how to make it as below.....</p>
  <pre><code>-----------------------------------
  |id   | name           | number   |
  -----------------------------------
  |  1  |albert amstrong | 18838327 |
  |     |                |          |
  |     |                |          |
  |     |                |          |
  </code></pre>
  <p>my php code</p>
  <pre><code> public function index_post()
  {
          $data = $this-&gt;post('data');
          $data = json_decode($data);
          $sth=$this-&gt;db-&gt;prepare('INSERT INTO kontak SET name=?, number=?');
          $sth-&gt;execute(array_map('trim', explode(',', $data-&gt;data)));
  }           
  </code></pre>
  <p>error message:</p>
  <pre><code>    &lt;h4&gt;An uncaught Exception was encountered&lt;/h4&gt;
  
  &lt;p&gt;Type: Error&lt;/p&gt;
  &lt;p&gt;Message: Call to undefined method CI_DB_mysqli_driver::prepare()&lt;/p&gt;
  &lt;p&gt;Filename: /home/dokdafta/domains/donkeys.xyz/public_html/wa/application/controllers/api/Okaja.php&lt;/p&gt;
  &lt;p&gt;Line Number: 42&lt;/p&gt;
  </code></pre>