Php calls mssql stored procedure instance _ PHP Tutorial

Source: Internet
Author: User
Php calls the mssql stored procedure instance application. Use the mssql_init statement to initialize the stored procedure, then call the mssql_bind statement to specify the stored procedure parameters, and finally call mssql_execute to execute the stored procedure. The php Tutorial calls the mssql stored procedure and uses the mssql_init statement to initialize the stored procedure. then, the mssql_bind statement is called to specify the stored procedure parameters, and mssql_execute is called to execute the stored procedure.

Php Tutorial call mssql stored procedure instance application

Use the mssql_init statement to initialize the stored procedure, then call the mssql_bind statement to specify the stored procedure parameters, and finally call mssql_execute to execute the stored procedure.
*/

// Connect to the mssql database tutorial server

$ Link = mssql_connect ("127.0.0.1", "sa", "sa") or die ("Can't connect SQL server ");
Mssql_select_db ("frrc", $ link) or die ("Select database failure ");

// Initialize and load the stored procedure Bigdatabase

$ Stmt = mssql_init ("Bigdatabase", $ link) or die ("initialize stored procedure failure ");
Mssql_bind ($ stmt, "@ pagesize", $ pagesize, SQLINT4 );
Mssql_bind ($ stmt, "@ start", $ start, SQLINT4 );
@ $ Ms_result = mssql_execute ($ stmt, false );
Mssql_query ("dump transaction tempdb WITH NO_LOG ");

Do {
While ($ ms_rs = mssql_fetch_object ($ ms_result ))
{
// Process data
}
}

// The msssql stored procedure Bigdatabase is as follows:

/*
Create procedure Bigdatabase
@ Pagesize int,
@ Start int
AS
Declare @ bsql nvarchar (4000)
Set @ bsql = 'SELECT top '+ str (@ pagesize) + 'username, jobid, password, useremail, zcdata, ip, name, xingbie, minzu, xueli, hunyin, age, example, zyclass, example, huji, huji1, shengao, byear, birthyear, birthmonth, birthday, dianhua, qq, Hangzhou, selectedjob1, selectedjob2, selectedjob3, s_PWL1, s_PWL2, s_PWL3, protocol, Negotiable, protocol, availOpts, availNotice, llcs, CONVERT (varchar (100), dlsj, 25) as dlsj, xgsj, dlcs, primary, primary age_one, l_OneAbility, primary age_two, l_twoAbility, mandarinLevel, skillkey, jingyan, photopb, photo, phototre, mbsys, codetype, code, shouji, posts, address, jobtype, convert (varchar (8000), pingjia) as large, convert (varchar (8000), jinengzhuanchang) as jinengzhuanchang, convert (varchar (8000), fazhanfangxiang) as fazhanfangxiang, convert (varchar (8000), other) as other from person where id not in (select top '+ str (@ start) + 'Id from person order by id asc) order by id asc'
Execute sp_executesql @ bsql
GO

Note: text must be converted to varchar. otherwise, problems may occur.

The original article on this site is Reprinted and indicated that the source is www. bKjia. c0m, the first stop of the Chinese WEB site

Bytes. Php Tutorial call mssql stored procedure...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.