Hello friends,
I handed over when use store procedure in one of my project in php with use of MySQL.
MySQL 5 is support store procedure. you must use the sqlyog for this functionality.
select one of the database. For example my database name is "project"
create table
CREATE TABLE `users` (
`u_id` int(11) NOT NULL auto_increment,
`u_fname` varchar(255) NOT NULL,
`u_email` varchar(255) NOT NULL,
`user` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`u_add` varchar(255) NOT NULL,
`u_phone` varchar(255) NOT NULL,
`u_active` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`u_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
Now for create new procedure right click on "store procedure" enter the name of your new procedure sp_insert
DELIMITER $$
DROP PROCEDURE IF EXISTS `project`.`sp_insert`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_insert`(id int , ufname varchar(255),uemail varchar(255),uuser varchar(255),
upswd varchar(255),uadd varchar(255),uphone varchar(255),uactive enum('0','1'))
BEGIN
insert into users values('',ufname,uemail,uuser,upswd,uadd,uphone,uactive);
END$$
DELIMITER ;
press F5 for run your procedure you will get the message "create successfully" or (0 rows affected).
Next step go to the query tab and write
call sp_insert('null','test','test@gmail.com','test','testing123',
'xxx','123-768','0');
That's all end you will get the result.
No comments:
Post a Comment