title: How to convert query result object into string in CodeIgniter
body: <p>I have the following code in my controller:</p>
  
  <pre><code>    $sql = "SELECT MAX(roll) FROM student WHERE department = '".$this-&gt;db-&gt;escape_str($sdata['department'])."'";
      $query = $this-&gt;db-&gt;query($sql);
  </code></pre>
  
  <p>Nothing wrong with it. I'm getting my expected value.</p>
  
  <p>However, when I try to use this value somewhere else as a string, like the following:</p>
  
  <pre><code>   $rolltext = substr($query-&gt;result(), 9);
     print_r($rolltext);
     die();
  </code></pre>
  
  <p>And then run the application in localhost, I get the following error:</p>
  
  <pre><code>    A PHP Error was encountered
  
      Severity: Warning
  
      Message: substr() expects parameter 1 to be string, array given
  </code></pre>
  
  <p>I know that the variable $rolltext is getting query result in the form of an array, instead of string, which is incorrect in terms of syntax of the <code>substr()</code> function. That's why I'm getting this error. My question is: How can I convert this query result into a string and perform my substr() operations in the subsequent lines? I didn't find a specific solution/guideline for such case in the CodeIgniter user guide, that's why I'm asking here.</p>