'2018/04'에 해당되는 글 1건

  1. 2018.04.25 mysql dbdriver call store procedure in codeigniter(ci)

mysql dbdriver call store procedure in codeigniter(ci)

php 2018.04.25 18:01

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=`directsend`@`223.130.121.254` 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"];

}





Trackback 0 : Comment 0