I am new to Codeigniter and PHP..
while doing some operations i have some doubts ,especially in the database libraries .
$get = "select filed_1 from tbl_ctc where ctc=?";
$get = $this->db->query($get,array($ctc_n));
if ($get)
{
//do some operations
}
else
{
//do some another operations
}
What will be the return value of $get if it is success ?
Expecting opinion & suggestion [downvotes too]
Thank you.
What “opinions and suggestions” do you expect?
The query() method returns a result object when you use read queries (like a select), while with write queries (like an insert or update) it returns TRUE or FALSE.
In case of a SELECT, i.e., you might want to check if it has any result:
While, in case of an INSERT for ex.:
Note that if you are using Active Record, you’ll have the
result()/row()andresult_array()/row_array()methods that will return either a full object/array or an empty one, so you’ll need to check for those values instead.