




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
PHPMYSQL類PAGEPAGE2————————————————————————————————作者:————————————————————————————————日期:PHPMYSQLMySQL。指定表和字段創(chuàng)DELETE語。創(chuàng)SQLWHERE,使LEFTJOIN和ORDER例子:<?php/********************************************************************ExamplefileThisexampleshowshowtousetheMyLibSQLGenclassTheexampleisbasedonthefollowingMySQLtable:(idint(10)unsignedNOTNULLauto_increment,namevarchar(60)NOTNULLdefault",addressvarchar(60)NOTNULLdefault”,cityvarchar(60)NOTNULLdefault”,PRIMARYKEY(cust_id))TYPE=MyISAM;********************************************************************/e(”n—0p”s=y("e”,”s","y";values=Array(”Fadjar","ResultmangRayaStreet”,”Jakarta”);tables=Array(”customer”);44echo”〈b>ResultGenerateInsert</b>br>";t=wn;object->clear_all_assign();//torefreshallpropertybutitnoneedwhenfirsttimeexecuteobject->setFields(fields);object->setValues(values);t>(s;f(!t〉)ot;t}else{sql=object〉echosql.”<br>”;}echo”〈b>ResultGenerateUpdate〈/b〉<br>";fields=Array(”name”,”address”,"city”);values=Array("Fadjar”,”ResultmangRayaStreet",”Jakarta”);tables=Array(”customer”);id=1;conditions[0][”condition”]=”id='id’”;conditions[0]["connection”]=“";object-〉clear_all_assign();object—>setFields(fields);object—>);object->tables);object->setConditions(conditions);f(!tL{ot>r;telse{sql=object〉Result;echosql.”<br>”;}echo”<b>ResultGenerate/b>〈〉”;s=y(”r”;s[0[”n”]=”=1′";s[0[”n”]="R";s[1[”n”]=”2′”;conditions[1]["connection”]=”O(jiān)R";s[2["n”]=”=′”;conditions[2][”connection"]=“”;PAGE5PAGE5objectclear_all_assign();t(s;t>(s;f(tL{ot;t}elsesqlobject—Resultechosql”<br”;}echo” 〈ResultGenerateList/b>br;s=y”id” ,"e”,”s” ,”y” ;s=y"r”id=1;conditions[0]["condition"]=”id='id'”;conditions[0][”connection"]=“”;t;t>ss;ts;t-ss;f(totrt}e{l=tol.”r”echo” 〈ResultGenerateListwithsearchonallfields</bbr;s=y("d” ,”e",”s”,”y” ;s=y"r” id=1;search=”FadjarNurswanto";t);t>(s;t>(s);t-hf(t{ot—rt}e{l=tol。"b”echo”ResultGenerateListwithsearchonsomefields〈/b〈br” ;s=y”id””e",”s”,”y”;s=y(”r”;id=1;search=Array(”name”=>”FadjarNurswanto",”address””);t;t—ss);ts;t—(h;f(!t—(otrte{l=t—>;ol。”r”}?>類代碼:<?php/*CreatedByFadjarNurswanto<fajr_n@〉E:—PRODUCTNAME:classMyLibSQLGenPRODUCTVERSION:1.0.0DESCRIPTION:classyangberfungsiuntukmenggenerateSQLDENPENCIES:*/classMyLibSQLGen{varResult;rs=y(;rs=y(;rs=y;rs=yvarCondition;rn=y;varSearch;varSort=”ASC”;varOrder;varError;n}functionBuildCondition(){funct=”BuildCondition”;e=sss=s—fs{s—>(tnef(!y(s)){this—ErrorclassName::funct\nVariableconditionsnotArray;return;}r(i=0itsi){sns[i"n”.””.s[i”connection”]?!薄?;}returntrue;}n){funct=”BuildLeftJoin”;e=s(sf!s—>{sr=”tnsy”;n}s=s—>(;hasil=false;foreach(LeftJoinVarsasLeftJoinVar){@l”TN”。r[”e”;h(r"n"]sr)PAGE8PAGE8{rr”n”].””。r”n”]?!薄?;}hasil。=”O(jiān)N(”。condvar。")”;unset(condvar);}thisResultLeftJoin=hasil;returntrue;}functionBuildOrder(){funct="BuildOrder”;className=get_class(this);—”sy”;n}f(!s—〉ssr=”tFieldswasempty";return;}s=s〉s;Orders=this—getOrder();f(g(”,”,s){s=e(”,”,r}if(!y(ss=y(s}foreach(OrdersasOrder){if(!c(rs—〉r="trtc”;n}f(r>t(s)sr=”tvalueofpropertySortis”。count(this->Fields);return;}@r=sr].”,”;}s—>r=”RY”.r(r,0— 1;99returntrue;}nh{funct="BuildSearch";e=s(s);f(!s-hsr=”thsy”;n}f(!s—sr=”tysy”n}s=s—;e=s-hfye){foreach(Fieldsasfield){f@ed){s=e"”ed;(as){@hasilfield”LIKE””%OR;}fl){@l。=””.r(l0-4?!?D”;t(l);}}}hasil=hasil_final;}else{PAGE11PAGE11hssd){Values=explode(”",xvalue);foreach(ValuesasValue){@hasil。=field。”LIKE‘%"。Value.”%'OR”;}}}s>h=r(l,0,-4;returntrue;}nn{this-〉Result=null;thisResultSearchnullResultLeftJoinnullResultnull;s—〉s=y(;s— >s=y(;s— >s=y;ss=y(;this— >Condition=null;thisLeftJoinArraythis— 〉Sort=”ASC;this— >Order=null;this— Search=null;this-〉fieldSQL=null;this-〉valueSQL=null;this— 〉partSQL=null;this— >Error=nullreturntrue;}functionCombineFieldValue(manual=false){funct=”CombineFieldsPostVar";e=sss=ss);valuesthis—fys{s>r="etesty”;return;}ifys){s>r=":testy”;return;}f(ts=ts){thisErrorofandnot;return}fori=0i<ts;i+){sLs[i]?!?”;([i]””[i]”"||[i]””){s>L=”(‘”.s[i].”,”;s>L=s[i].”(‘”.s[i]。””;}else{fc(s[i]){@this—>valueSQL。=values[i].”,”;@this—partSQLfields[i].””values[i””;}else{s-L。=”‘”。s[i]?!?”;s>L=s[i].”=’"。s[i]。",";}}}}s>L=rsL01;s>L=rs—>L0,—1;sL=rsL,0—1;returntrue;}n{t=L";e=sss=s>s;f(s|t(s){thisdbgFailedfuncts>r="etesy;return;}fori=0;itsi){@e。=s[i]。";}Table=substr(Table,0,—1);l=EM.e;fs>(){f(!s—>){s>t;n}l="E.s>;}this—>Result=sql;returntrue;}functiongetInsertSQL(){funct=”getInsertSQL”;e=ss;f!s—>)s>r=”etssy”n}f(s—>ss—>r=”etssy”n}fs{s—r=”etssy”n}f(s)s(t;n}s=s—l=”TO”。s[0].””。s-L.”(”。this—>valueSQL.”)”;thisResultsql;returntrue;}n){funct="getUpdateSQL”;className=get_class(this);f(s—({s-r=”tssy”;n;}fs>() s>r="tysy"n;}f(!s—>){s—r="etssy”;n;}f!s—>(s—>tn}f(s—({sdtn}s=s—;sql””0”””this-n;this->Result=sql;returntrue;}functiongetQuerySQL(){funct=”getQuerySQL”;e=ss;f(s—>() sr=”tysy”n}f!s-s{s—>r=”tssy”;n}s=s—>s);s=ss);hssd@wd",”hsse@ee.”,”}s—>t="T"r(w,0,— 1)”M".(e,0— 1;fsn{if(s—s){s—tnthisResult””this—ResultLeftJoin;}f(s>)){if!s—ns—(tns—t”E”s—>n.””;}fs—)){f(!s-){s-(t)nfs)PAGEPAGE15{f(i("E”s—>ts—>t=”D”.sResultSearch;}else{this-〉Result.=”WHERE”。this-〉ResultSearch;}}}if(s〉()){f(!s—>r){s-〉(tnthisResult?!薄眛his—ResultOrder;}if(this-〉getSort(){if(@this->ResultOrder){this—〉Result。=”"。this-〉getSort();}}returntrue;}functiongetCondition(){return@t
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025牲畜交易合同
- 2025養(yǎng)殖設(shè)備采購合同模板
- 竣工驗(yàn)收項(xiàng)目經(jīng)理發(fā)言稿
- O2O生活服務(wù)平臺開發(fā)及運(yùn)營合同
- 2025機(jī)電安裝施工合同
- 2025標(biāo)準(zhǔn)版深圳市國內(nèi)旅游合同
- 農(nóng)產(chǎn)品冷鏈物流技術(shù)升級與智能化管理方案
- 2025辦公室租賃合同樣本
- 人體力量檢測課件
- 智能網(wǎng)聯(lián)汽車技術(shù)知到課后答案智慧樹章節(jié)測試答案2025年春陜西工業(yè)職業(yè)技術(shù)學(xué)院
- 廠房工程起重吊裝施工方案
- 《體育繪圖》課程教學(xué)大綱
- 2025-2030年中國衛(wèi)星導(dǎo)航行業(yè)商業(yè)模式創(chuàng)新戰(zhàn)略制定與實(shí)施研究報告
- 護(hù)患溝通技巧課件
- 《醫(yī)學(xué)科研概述》課件
- 學(xué)習(xí)《中國近現(xiàn)代史綱要》心得體會
- GB/T 22082-2024預(yù)制混凝土襯砌管片
- 肝性腦病護(hù)理診斷及措施
- 7 《包身工》任務(wù)式公開課一等獎創(chuàng)新教學(xué)設(shè)計統(tǒng)編版高中語文選擇性必修中冊
- 肉牛育肥基地建設(shè)項(xiàng)目可行性研究報告書
- 《阻燃材料與技術(shù)》課件 第5講 阻燃塑料材料
評論
0/150
提交評論