Create a visitors table and create some basic Store Procedures.
create_visitors
CREATE DEFINER=`root`@`localhost` PROCEDURE `create_visitors`
(in $first_name varchar(45),in $last_name varchar(45),in $mobile varchar(20),in $othercontact varchar(20),in $email varchar(30),in $location varchar(45),in $detail varchar(300),in $towhom bigint(20),in $gender tinyint(1),in $category varchar(20),in $collegeid bigint(20),in $accountid bigint(20),in $city varchar(20),in $pin varchar(10),in $distict varchar(20),in $country varchar(20))
BEGIN
INSERT INTO visitors
(ondate, first_name, last_name, mobile, othercontact, email, location, detail, towhom, gender, category, collegeid, accountid,city, pin, distict, country)
VALUES
(UTC_TIMESTAMP(),upper($first_name),upper($last_name),$mobile,$othercontact,$email,$location,$detail,$towhom,$gender,$category,$collegeid,$accountid,$city, $pin, $distict, $country);
if ROW_COUNT()=1 then
select LAST_INSERT_ID() as id;
else
select 0 as id;
END IF;
END
read_visitors
CREATE DEFINER=`root`@`localhost` PROCEDURE `read_visitors`
(in $collegeid bigint(20),in $startindex bigint(20),in $noofrows tinyint )
BEGIN
select id,ondate,first_name,last_name,mobile,location,pic,gender,category,isseen
from visitors
where collegeid=$collegeid
order by id desc
limit $startindex,$noofrows;
select COUNT(id) as rowsno
from visitors
where collegeid=$collegeid;
END
read_visitors detail
CREATE DEFINER=`root`@`localhost` PROCEDURE `read_visitorsdetail`
(in $id bigint(20),in $collegeid bigint(20))
BEGIN
select id, ondate, first_name, last_name, mobile, othercontact, email, location, detail, towhom, isseen, pic, gender, category,city, pin, distict, country
from visitors
where id=$id and collegeid=$collegeid;
END
update_visitors_pic
CREATE DEFINER=`root`@`localhost` PROCEDURE `update_visitors_pic`
(in $id bigint(20),in $pic varchar(150),in $collegeid bigint(20))
BEGIN
update visitors
set pic=$pic
where id=$id and collegeid=$collegeid;
END
No comments:
Post a Comment