I think, How to use stored function and stored procedure with MySQL like SQL Server and Oracle. So, I have some R & D this topics then I have decided write a basic(stored function and stored procedure) WP article as follows

Here, MySQL database table raw structure

CREATE TABLE IF NOT EXISTS `tbl_test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `aa` int(11)  NOT NULL,
  `bb` int(11)  NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;

Here, MySQL stored procedure raw structure for “tbl_test” Table

// Storeprocedure ------------------START HERE
	DELIMITER $$

	DROP PROCEDURE IF EXISTS `tbl_test`.`spInsert`$$
  
    // create "spInsert" stored procedure with list of paramaters

        DEFINER is mandatory. if you use it's means set a user for this stored procedure 
	CREATE DEFINER=`root`@`localhost` PROCEDURE `spInsert`(in a int, in b int, out ret int)

       // Not use DEFINER means it's use any user 
	CREATE  PROCEDURE `spInsert`(in a int, in b int, out ret int)

	BEGIN
		
		 declare exit handler for not found rollback;
		 declare exit handler for sqlwarning rollback;
		 declare exit handler for sqlexception rollback;  
		 
		 set ret=0;
		 
		 START TRANSACTION; 
		 
		   insert into tbl_test (aa, bb) values(a,b);   
		   insert into tbl_test (aa, bb) values(a,b);   
	 
	   
		COMMIT; 
		set ret=1;
		
	END$$

	DELIMITER ;
    // Stored procedure ------------------END HERE 

Here, How to call stored procedure from PHP