php - MySQLi get last insert ID and pass it true function -


in trying retrieve last_insert (id) query true calling function here call function:

$lead = $_leadh->addlead($lead_data, $call_data['number'], $user); $leadid = $lead['id']; 

i not getting result? addlead function:

function addlead(array  $lead_data, $number, $user) {                         //check if lead same number , name exist in db         if ($checker =  >= 1)         {             //return lead id existed             $data = $query->fetch_array(mysqli_assoc);                   return array('id'=>$data['lead_id'], 'exists'=>true);                    }         else         {             //insert new lead db             if ($query = $this->querydb("insert", "into leads (lead_name)                                                values ('".$this->escapestring($lead_data['lead_name'])))               {                   //return lead id new                   return array('id'=>$this->insert_id, 'exists'=>false);               }               else                {                  //output error if insertion fail                          return false;               } }} 

you returning array addlead function while calling not getting in variable:

$_leadh->addlead($lead_data, $call_data['number'], $user); $leadid = $lead['id']; 

should below:

$lead = $_leadh->addlead($lead_data, $call_data['number'], $user); $leadid = $lead['id']; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -