mysql dbdriver call store procedure in codeigniter(ci)

php 2018.12.17 14:19

mysql dbdriver call store procedure in codeigniter(ci)




<!-- php -->


$sql = "CALL .sp(@out1);";


$this->db->query($sql);            


$query = $this->db->query("SELECT @out1");




$result_temp = array();




if($query->num_rows() > 0)


$result_temp = $query->result_array();








<!-- mysql -->


CREATE DEFINER=`id`@`ip` PROCEDURE `sp`( 


OUT `last_id` INT


)


BEGIN




SET last_id = "test";




END$$




DELIMITER ;






<!-- codeigniter system/database/DB_active_rec.php -->




/**


* "Count All Results" query


*


* Generates a platform-specific query string that counts all records


* returned by an Active Record query.


*


* @param string


* @return string


*/


public function count_all_results($table = '')


{


if ($table != '')


{


$this->_track_aliases($table);


$this->from($table);


}




$sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows'));




$query = $this->query($sql);


 


$result_temp = $query->result();




$array_temp = json_decode(json_encode($result_temp[0]), True);




$this->_reset_select();




if ($array_temp["numrows"] == 0)


{


return 0;


}




return (int) $array_temp["numrows"];


}



Trackbacks 0 : Comments 0