Business Websites, Ecommerce solution, Process Automation!

Call to undefined method CI_DB_mysqli_driver::_error_number()

  Posted in Codeigniter | 27th July, 2018

Tags.

If you are a codeigniter developer   and you are in the middle of a project scratching your heard asking why you cannot get a DB insert/delete success message determined, you are in the right place. You may not be doing anything wrong.

 

Here is a sample code that can generate the error message:Call to undefined method CI_DB_mysqli_driver::_error_number()

 

$report=array();
        $report['error']=$this->db->_error_number();
        $report['message']=$this->db->_error_message();
        if(!$report['error'])
        {
            return true;
        }else
        {
            $this->logmessage('error', 'Attempted to delete user ' . $report['error'] . ' failed (MySQL Error:' . mysql_error() . ')');
            return false;
        }

The Codeigniter function $this->db->_error_message() has been deprecated and will no longer work in the newer versions of codeigniter.

This error message can be fixed by changing the call

from $this->db->_error_message()

to

$this->db->error();

This method's response will return an array  containing code (1 or 0 )and an error message

Your new function should  be updated as fillows:

 

$report=$this->db->error();;
      
        
     
        if($report['code']==0)
        {

            //all good
            return true;
        }else
        {
         
            echo      $report['message'];
            return false;
        }

01

Build YourWebsites

>>
Showcase your business online! Whether you need a website for your associations,business, ecommerce or affiliate marketing Call us Now
02

MaintainWeb Assets

Maintain Your Web Assets To ensure optimal performance and 99.9% uptime.We help you fix issues,on-page SEO optimization
03

Build NewAdd-ons

>>
We help our Clients to add new features: Additional pages, add payment gateway, load products to your store or build a new e-commerce store.