php 調用mssql預存程序執行個體應用_PHP教程

來源:互聯網
上載者:User
用mssql_init語句用於初始化預存程序,而後調用mssql_bind語句指定預存程序參數,最後調用mssql_execute執行預存程序。

php教程 調用mssql預存程序執行個體應用

用mssql_init語句用於初始化預存程序,而後調用mssql_bind語句指定預存程序參數,最後調用mssql_execute執行預存程序。
*/

//串連mssql資料庫教程伺服器

$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");

//初始化並載入預存程序 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) )
{
//進行資料處理
}
}

// msssql 預存程序 Bigdatabase如下

/*
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,xuexiao,zyclass,zhuanye,x_suozaidi,x_suozaidi1,huji,huji1,shengao,byear,birthyear,birthmonth,birthday,dianhua,qq,gerenzhuye,selectedjob1,selectedjob2,selectedjob3,s_PWL1,s_PWL2,s_PWL3,daiyuyaoqiu,Negotiable,provideHouseNeeded,availOpts,availNotice,llcs,CONVERT(varchar(100),dlsj, 25) as dlsj,xgsj,dlcs,jsjshuiping,language_one,l_OneAbility,language_two,l_twoAbility,mandarinLevel,skillkey,jingyan,photopb,photo,phototre,mbsys,codetype,code,shouji,posts,address,jobtype,convert(varchar(8000),pingjia) as pingjia ,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

註:必須把text轉換成varchar來處理,否則會出問題

本站原創文章轉載註明來源於www.bKjia.c0m 中國WEB第一站

http://www.bkjia.com/PHPjc/630876.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630876.htmlTechArticle用mssql_init語句用於初始化預存程序,而後調用mssql_bind語句指定預存程序參數,最後調用mssql_execute執行預存程序。 php教程 調用mssql預存程序...

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.