docs-adodb.htm 327 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178
  1. <html xmlns:v="urn:schemas-microsoft-com:vml"
  2. xmlns:o="urn:schemas-microsoft-com:office:office"
  3. xmlns:w="urn:schemas-microsoft-com:office:word"
  4. xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
  5. xmlns="http://www.w3.org/TR/REC-html40">
  6. <head>
  7. <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
  8. <meta name=ProgId content=Word.Document>
  9. <meta name=Generator content="Microsoft Word 11">
  10. <meta name=Originator content="Microsoft Word 11">
  11. <link rel=File-List href="docs-adodb_files/filelist.xml">
  12. <link rel=Edit-Time-Data href="docs-adodb_files/editdata.mso">
  13. <!--[if !mso]>
  14. <style>
  15. v\:* {behavior:url(#default#VML);}
  16. o\:* {behavior:url(#default#VML);}
  17. w\:* {behavior:url(#default#VML);}
  18. .shape {behavior:url(#default#VML);}
  19. </style>
  20. <![endif]-->
  21. <title>ADODB Manual</title>
  22. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  23. name="State"/>
  24. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  25. name="PlaceType"/>
  26. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  27. name="PlaceName"/>
  28. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  29. name="country-region"/>
  30. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  31. name="City"/>
  32. <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
  33. name="place"/>
  34. <!--[if gte mso 9]><xml>
  35. <o:DocumentProperties>
  36. <o:Author>John</o:Author>
  37. <o:LastAuthor>John</o:LastAuthor>
  38. <o:Revision>3</o:Revision>
  39. <o:TotalTime>3</o:TotalTime>
  40. <o:Created>2008-12-24T10:43:00Z</o:Created>
  41. <o:LastSaved>2008-12-24T10:46:00Z</o:LastSaved>
  42. <o:Pages>73</o:Pages>
  43. <o:Words>30239</o:Words>
  44. <o:Characters>172366</o:Characters>
  45. <o:Company> </o:Company>
  46. <o:Lines>1436</o:Lines>
  47. <o:Paragraphs>404</o:Paragraphs>
  48. <o:CharactersWithSpaces>202201</o:CharactersWithSpaces>
  49. <o:Version>11.9999</o:Version>
  50. </o:DocumentProperties>
  51. </xml><![endif]--><!--[if gte mso 9]><xml>
  52. <w:WordDocument>
  53. <w:Zoom>140</w:Zoom>
  54. <w:FormsDesign/>
  55. <w:ValidateAgainstSchemas/>
  56. <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  57. <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  58. <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  59. <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  60. </w:WordDocument>
  61. </xml><![endif]--><!--[if gte mso 9]><xml>
  62. <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
  63. </w:LatentStyles>
  64. </xml><![endif]--><!--[if !mso]><object
  65. classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
  66. <style>
  67. st1\:*{behavior:url(#ieooui) }
  68. </style>
  69. <![endif]-->
  70. <style>
  71. <!--
  72. f
  73. /* Font Definitions */
  74. @font-face
  75. {font-family:Helvetica;
  76. panose-1:2 11 6 4 2 2 2 2 2 4;
  77. mso-font-charset:0;
  78. mso-generic-font-family:swiss;
  79. mso-font-format:other;
  80. mso-font-pitch:variable;
  81. mso-font-signature:3 0 0 0 1 0;}
  82. @font-face
  83. {font-family:Courier;
  84. panose-1:2 7 4 9 2 2 5 2 4 4;
  85. mso-font-charset:0;
  86. mso-generic-font-family:modern;
  87. mso-font-format:other;
  88. mso-font-pitch:fixed;
  89. mso-font-signature:3 0 0 0 1 0;}
  90. @font-face
  91. {font-family:"Tms Rmn";
  92. panose-1:2 2 6 3 4 5 5 2 3 4;
  93. mso-font-charset:0;
  94. mso-generic-font-family:roman;
  95. mso-font-format:other;
  96. mso-font-pitch:variable;
  97. mso-font-signature:3 0 0 0 1 0;}
  98. @font-face
  99. {font-family:Helv;
  100. panose-1:2 11 6 4 2 2 2 3 2 4;
  101. mso-font-charset:0;
  102. mso-generic-font-family:swiss;
  103. mso-font-format:other;
  104. mso-font-pitch:variable;
  105. mso-font-signature:3 0 0 0 1 0;}
  106. @font-face
  107. {font-family:"New York";
  108. panose-1:2 4 5 3 6 5 6 2 3 4;
  109. mso-font-charset:0;
  110. mso-generic-font-family:roman;
  111. mso-font-format:other;
  112. mso-font-pitch:variable;
  113. mso-font-signature:3 0 0 0 1 0;}
  114. @font-face
  115. {font-family:System;
  116. panose-1:0 0 0 0 0 0 0 0 0 0;
  117. mso-font-charset:0;
  118. mso-generic-font-family:swiss;
  119. mso-font-format:other;
  120. mso-font-pitch:variable;
  121. mso-font-signature:3 0 0 0 1 0;}
  122. @font-face
  123. {font-family:Wingdings;
  124. panose-1:5 0 0 0 0 0 0 0 0 0;
  125. mso-font-charset:2;
  126. mso-generic-font-family:auto;
  127. mso-font-pitch:variable;
  128. mso-font-signature:0 268435456 0 0 -2147483648 0;}
  129. @font-face
  130. {font-family:"MS Mincho";
  131. panose-1:2 2 6 9 4 2 5 8 3 4;
  132. mso-font-alt:"\FF2D\FF33 \660E\671D";
  133. mso-font-charset:128;
  134. mso-generic-font-family:roman;
  135. mso-font-format:other;
  136. mso-font-pitch:fixed;
  137. mso-font-signature:1 134676480 16 0 131072 0;}
  138. @font-face
  139. {font-family:Batang;
  140. panose-1:2 3 6 0 0 1 1 1 1 1;
  141. mso-font-alt:\BC14\D0D5;
  142. mso-font-charset:129;
  143. mso-generic-font-family:auto;
  144. mso-font-format:other;
  145. mso-font-pitch:fixed;
  146. mso-font-signature:1 151388160 16 0 524288 0;}
  147. @font-face
  148. {font-family:SimSun;
  149. panose-1:2 1 6 0 3 1 1 1 1 1;
  150. mso-font-alt:\5B8B\4F53;
  151. mso-font-charset:134;
  152. mso-generic-font-family:auto;
  153. mso-font-format:other;
  154. mso-font-pitch:variable;
  155. mso-font-signature:1 135135232 16 0 262144 0;}
  156. @font-face
  157. {font-family:PMingLiU;
  158. panose-1:2 2 3 0 0 0 0 0 0 0;
  159. mso-font-alt:\65B0\7D30\660E\9AD4;
  160. mso-font-charset:136;
  161. mso-generic-font-family:auto;
  162. mso-font-format:other;
  163. mso-font-pitch:variable;
  164. mso-font-signature:1 134742016 16 0 1048576 0;}
  165. @font-face
  166. {font-family:"MS Gothic";
  167. panose-1:2 11 6 9 7 2 5 8 2 4;
  168. mso-font-alt:"\FF2D\FF33 \30B4\30B7\30C3\30AF";
  169. mso-font-charset:128;
  170. mso-generic-font-family:modern;
  171. mso-font-format:other;
  172. mso-font-pitch:fixed;
  173. mso-font-signature:1 134676480 16 0 131072 0;}
  174. @font-face
  175. {font-family:Dotum;
  176. panose-1:2 11 6 0 0 1 1 1 1 1;
  177. mso-font-alt:\B3CB\C6C0;
  178. mso-font-charset:129;
  179. mso-generic-font-family:modern;
  180. mso-font-format:other;
  181. mso-font-pitch:fixed;
  182. mso-font-signature:1 151388160 16 0 524288 0;}
  183. @font-face
  184. {font-family:SimHei;
  185. panose-1:2 1 6 0 3 1 1 1 1 1;
  186. mso-font-alt:\9ED1\4F53;
  187. mso-font-charset:134;
  188. mso-generic-font-family:modern;
  189. mso-font-format:other;
  190. mso-font-pitch:fixed;
  191. mso-font-signature:1 135135232 16 0 262144 0;}
  192. @font-face
  193. {font-family:MingLiU;
  194. panose-1:2 2 3 9 0 0 0 0 0 0;
  195. mso-font-alt:\7D30\660E\9AD4;
  196. mso-font-charset:136;
  197. mso-generic-font-family:modern;
  198. mso-font-format:other;
  199. mso-font-pitch:fixed;
  200. mso-font-signature:1 134742016 16 0 1048576 0;}
  201. @font-face
  202. {font-family:Mincho;
  203. panose-1:2 2 6 9 4 3 5 8 3 5;
  204. mso-font-alt:\660E\671D;
  205. mso-font-charset:128;
  206. mso-generic-font-family:roman;
  207. mso-font-format:other;
  208. mso-font-pitch:fixed;
  209. mso-font-signature:1 134676480 16 0 131072 0;}
  210. @font-face
  211. {font-family:Gulim;
  212. panose-1:2 11 6 0 0 1 1 1 1 1;
  213. mso-font-alt:\AD74\B9BC;
  214. mso-font-charset:129;
  215. mso-generic-font-family:roman;
  216. mso-font-format:other;
  217. mso-font-pitch:fixed;
  218. mso-font-signature:1 151388160 16 0 524288 0;}
  219. @font-face
  220. {font-family:Century;
  221. panose-1:2 4 6 4 5 5 5 2 3 4;
  222. mso-font-charset:0;
  223. mso-generic-font-family:roman;
  224. mso-font-format:other;
  225. mso-font-pitch:variable;
  226. mso-font-signature:3 0 0 0 1 0;}
  227. @font-face
  228. {font-family:"Angsana New";
  229. panose-1:2 2 6 3 5 4 5 2 3 4;
  230. mso-font-charset:222;
  231. mso-generic-font-family:roman;
  232. mso-font-format:other;
  233. mso-font-pitch:variable;
  234. mso-font-signature:16777217 0 0 0 65536 0;}
  235. @font-face
  236. {font-family:"Cordia New";
  237. panose-1:2 11 3 4 2 2 2 2 2 4;
  238. mso-font-charset:222;
  239. mso-generic-font-family:roman;
  240. mso-font-format:other;
  241. mso-font-pitch:variable;
  242. mso-font-signature:16777217 0 0 0 65536 0;}
  243. @font-face
  244. {font-family:Mangal;
  245. panose-1:0 0 4 0 0 0 0 0 0 0;
  246. mso-font-charset:1;
  247. mso-generic-font-family:roman;
  248. mso-font-format:other;
  249. mso-font-pitch:variable;
  250. mso-font-signature:32768 0 0 0 0 0;}
  251. @font-face
  252. {font-family:Latha;
  253. panose-1:2 0 4 0 0 0 0 0 0 0;
  254. mso-font-charset:1;
  255. mso-generic-font-family:roman;
  256. mso-font-format:other;
  257. mso-font-pitch:variable;
  258. mso-font-signature:1048576 0 0 0 0 0;}
  259. @font-face
  260. {font-family:Sylfaen;
  261. panose-1:1 10 5 2 5 3 6 3 3 3;
  262. mso-font-charset:0;
  263. mso-generic-font-family:roman;
  264. mso-font-format:other;
  265. mso-font-pitch:variable;
  266. mso-font-signature:16778883 0 512 0 13 0;}
  267. @font-face
  268. {font-family:Vrinda;
  269. panose-1:0 0 4 0 0 0 0 0 0 0;
  270. mso-font-charset:1;
  271. mso-generic-font-family:roman;
  272. mso-font-format:other;
  273. mso-font-pitch:variable;
  274. mso-font-signature:0 0 0 0 0 0;}
  275. @font-face
  276. {font-family:Raavi;
  277. panose-1:2 0 5 0 0 0 0 0 0 0;
  278. mso-font-charset:1;
  279. mso-generic-font-family:roman;
  280. mso-font-format:other;
  281. mso-font-pitch:variable;
  282. mso-font-signature:0 0 0 0 0 0;}
  283. @font-face
  284. {font-family:Shruti;
  285. panose-1:2 0 5 0 0 0 0 0 0 0;
  286. mso-font-charset:1;
  287. mso-generic-font-family:roman;
  288. mso-font-format:other;
  289. mso-font-pitch:variable;
  290. mso-font-signature:0 0 0 0 0 0;}
  291. @font-face
  292. {font-family:Sendnya;
  293. panose-1:0 0 4 0 0 0 0 0 0 0;
  294. mso-font-charset:1;
  295. mso-generic-font-family:roman;
  296. mso-font-format:other;
  297. mso-font-pitch:variable;
  298. mso-font-signature:0 0 0 0 0 0;}
  299. @font-face
  300. {font-family:Gautami;
  301. panose-1:2 0 5 0 0 0 0 0 0 0;
  302. mso-font-charset:1;
  303. mso-generic-font-family:roman;
  304. mso-font-format:other;
  305. mso-font-pitch:variable;
  306. mso-font-signature:0 0 0 0 0 0;}
  307. @font-face
  308. {font-family:Tunga;
  309. panose-1:0 0 4 0 0 0 0 0 0 0;
  310. mso-font-charset:1;
  311. mso-generic-font-family:roman;
  312. mso-font-format:other;
  313. mso-font-pitch:variable;
  314. mso-font-signature:0 0 0 0 0 0;}
  315. @font-face
  316. {font-family:"Estrangelo Edessa";
  317. panose-1:0 0 0 0 0 0 0 0 0 0;
  318. mso-font-charset:1;
  319. mso-generic-font-family:roman;
  320. mso-font-format:other;
  321. mso-font-pitch:variable;
  322. mso-font-signature:0 0 0 0 0 0;}
  323. @font-face
  324. {font-family:Kartika;
  325. panose-1:1 1 1 0 1 1 1 1 1 1;
  326. mso-font-charset:1;
  327. mso-generic-font-family:roman;
  328. mso-font-format:other;
  329. mso-font-pitch:variable;
  330. mso-font-signature:0 0 0 0 0 0;}
  331. @font-face
  332. {font-family:"Arial Unicode MS";
  333. panose-1:2 11 6 4 2 2 2 2 2 4;
  334. mso-font-charset:0;
  335. mso-generic-font-family:roman;
  336. mso-font-format:other;
  337. mso-font-pitch:variable;
  338. mso-font-signature:3 0 0 0 1 0;}
  339. @font-face
  340. {font-family:Tahoma;
  341. panose-1:2 11 6 4 3 5 4 4 2 4;
  342. mso-font-charset:0;
  343. mso-generic-font-family:swiss;
  344. mso-font-format:other;
  345. mso-font-pitch:variable;
  346. mso-font-signature:3 0 0 0 1 0;}
  347. /* Style Definitions */
  348. p.MsoNormal, li.MsoNormal, div.MsoNormal
  349. {mso-style-parent:"";
  350. margin:0cm;
  351. margin-bottom:.0001pt;
  352. mso-pagination:widow-orphan;
  353. font-size:12.0pt;
  354. font-family:"Times New Roman";
  355. mso-fareast-font-family:"Times New Roman";
  356. color:black;}
  357. h1
  358. {mso-margin-top-alt:auto;
  359. margin-right:0cm;
  360. mso-margin-bottom-alt:auto;
  361. margin-left:0cm;
  362. mso-pagination:widow-orphan;
  363. mso-outline-level:1;
  364. font-size:24.0pt;
  365. font-family:"Times New Roman";
  366. color:black;
  367. font-weight:bold;}
  368. h2
  369. {mso-margin-top-alt:auto;
  370. margin-right:0cm;
  371. mso-margin-bottom-alt:auto;
  372. margin-left:0cm;
  373. mso-pagination:widow-orphan;
  374. mso-outline-level:2;
  375. font-size:18.0pt;
  376. font-family:"Times New Roman";
  377. color:black;
  378. font-weight:bold;}
  379. h3
  380. {mso-margin-top-alt:auto;
  381. margin-right:0cm;
  382. mso-margin-bottom-alt:auto;
  383. margin-left:0cm;
  384. mso-pagination:widow-orphan;
  385. mso-outline-level:3;
  386. font-size:13.5pt;
  387. font-family:"Times New Roman";
  388. color:black;
  389. font-weight:bold;}
  390. h4
  391. {mso-margin-top-alt:auto;
  392. margin-right:0cm;
  393. mso-margin-bottom-alt:auto;
  394. margin-left:0cm;
  395. mso-pagination:widow-orphan;
  396. mso-outline-level:4;
  397. font-size:12.0pt;
  398. font-family:"Times New Roman";
  399. color:black;
  400. font-weight:bold;}
  401. a:link, span.MsoHyperlink
  402. {color:blue;
  403. text-decoration:underline;
  404. text-underline:single;}
  405. a:visited, span.MsoHyperlinkFollowed
  406. {color:blue;
  407. text-decoration:underline;
  408. text-underline:single;}
  409. p
  410. {font-size:12.0pt;
  411. font-family:"Times New Roman";
  412. mso-fareast-font-family:"Times New Roman";
  413. color:black;}
  414. code
  415. {font-family:"Courier New";
  416. mso-ascii-font-family:"Courier New";
  417. mso-fareast-font-family:"Times New Roman";
  418. mso-hansi-font-family:"Courier New";
  419. mso-bidi-font-family:"Courier New";}
  420. pre
  421. {margin:0cm;
  422. margin-bottom:.0001pt;
  423. mso-pagination:widow-orphan;
  424. tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
  425. background:#EEEEEE;
  426. border:none;
  427. mso-border-alt:solid #DDDDDD .75pt;
  428. padding:0cm;
  429. mso-padding-alt:9.0pt 18.0pt 9.0pt 18.0pt;
  430. font-size:9.0pt;
  431. font-family:"Courier New";
  432. mso-fareast-font-family:"Times New Roman";
  433. color:black;}
  434. span.msoIns
  435. {mso-style-type:export-only;
  436. mso-style-name:"";
  437. text-decoration:underline;
  438. text-underline:single;
  439. color:teal;}
  440. span.msoDel
  441. {mso-style-type:export-only;
  442. mso-style-name:"";
  443. text-decoration:line-through;
  444. color:red;}
  445. span.msoChangeProp
  446. {mso-style-type:export-only;
  447. mso-style-name:"";}
  448. @page Section1
  449. {size:612.0pt 792.0pt;
  450. margin:72.0pt 90.0pt 72.0pt 90.0pt;
  451. mso-header-margin:35.4pt;
  452. mso-footer-margin:35.4pt;
  453. mso-paper-source:0;}
  454. div.Section1
  455. {page:Section1;}
  456. /* List Definitions */
  457. @list l0
  458. {mso-list-id:3098366;
  459. mso-list-template-ids:-1654113918;}
  460. @list l0:level1
  461. {mso-level-number-format:bullet;
  462. mso-level-text:\F0B7;
  463. mso-level-tab-stop:36.0pt;
  464. mso-level-number-position:left;
  465. text-indent:-18.0pt;
  466. mso-ansi-font-size:10.0pt;
  467. font-family:Symbol;}
  468. @list l1
  469. {mso-list-id:118686534;
  470. mso-list-template-ids:1789952844;}
  471. @list l1:level1
  472. {mso-level-number-format:bullet;
  473. mso-level-text:\F0B7;
  474. mso-level-tab-stop:36.0pt;
  475. mso-level-number-position:left;
  476. text-indent:-18.0pt;
  477. mso-ansi-font-size:10.0pt;
  478. font-family:Symbol;}
  479. @list l2
  480. {mso-list-id:325595838;
  481. mso-list-template-ids:-924547596;}
  482. @list l2:level1
  483. {mso-level-number-format:bullet;
  484. mso-level-text:\F0B7;
  485. mso-level-tab-stop:36.0pt;
  486. mso-level-number-position:left;
  487. text-indent:-18.0pt;
  488. mso-ansi-font-size:10.0pt;
  489. font-family:Symbol;}
  490. @list l3
  491. {mso-list-id:577053254;
  492. mso-list-template-ids:1006266472;}
  493. @list l3:level1
  494. {mso-level-number-format:bullet;
  495. mso-level-text:\F0B7;
  496. mso-level-tab-stop:36.0pt;
  497. mso-level-number-position:left;
  498. text-indent:-18.0pt;
  499. mso-ansi-font-size:10.0pt;
  500. font-family:Symbol;}
  501. @list l4
  502. {mso-list-id:584261941;
  503. mso-list-template-ids:1672376844;}
  504. @list l4:level1
  505. {mso-level-number-format:bullet;
  506. mso-level-text:\F0B7;
  507. mso-level-tab-stop:36.0pt;
  508. mso-level-number-position:left;
  509. text-indent:-18.0pt;
  510. mso-ansi-font-size:10.0pt;
  511. font-family:Symbol;}
  512. @list l5
  513. {mso-list-id:678311197;
  514. mso-list-template-ids:-1025849406;}
  515. @list l5:level1
  516. {mso-level-number-format:bullet;
  517. mso-level-text:\F0B7;
  518. mso-level-tab-stop:36.0pt;
  519. mso-level-number-position:left;
  520. text-indent:-18.0pt;
  521. mso-ansi-font-size:10.0pt;
  522. font-family:Symbol;}
  523. @list l6
  524. {mso-list-id:993068284;
  525. mso-list-template-ids:-1149100626;}
  526. @list l6:level1
  527. {mso-level-number-format:bullet;
  528. mso-level-text:\F0B7;
  529. mso-level-tab-stop:36.0pt;
  530. mso-level-number-position:left;
  531. text-indent:-18.0pt;
  532. mso-ansi-font-size:10.0pt;
  533. font-family:Symbol;}
  534. @list l7
  535. {mso-list-id:1120344907;
  536. mso-list-template-ids:-1732590280;}
  537. @list l7:level1
  538. {mso-level-number-format:bullet;
  539. mso-level-text:\F0B7;
  540. mso-level-tab-stop:36.0pt;
  541. mso-level-number-position:left;
  542. text-indent:-18.0pt;
  543. mso-ansi-font-size:10.0pt;
  544. font-family:Symbol;}
  545. @list l8
  546. {mso-list-id:1134718884;
  547. mso-list-template-ids:-1854392276;}
  548. @list l8:level1
  549. {mso-level-number-format:bullet;
  550. mso-level-text:\F0B7;
  551. mso-level-tab-stop:36.0pt;
  552. mso-level-number-position:left;
  553. text-indent:-18.0pt;
  554. mso-ansi-font-size:10.0pt;
  555. font-family:Symbol;}
  556. @list l9
  557. {mso-list-id:1289897560;
  558. mso-list-template-ids:-1284101662;}
  559. @list l9:level1
  560. {mso-level-number-format:bullet;
  561. mso-level-text:\F0B7;
  562. mso-level-tab-stop:36.0pt;
  563. mso-level-number-position:left;
  564. text-indent:-18.0pt;
  565. mso-ansi-font-size:10.0pt;
  566. font-family:Symbol;}
  567. @list l10
  568. {mso-list-id:1461026030;
  569. mso-list-template-ids:65944450;}
  570. @list l11
  571. {mso-list-id:1566380536;
  572. mso-list-template-ids:395727058;}
  573. @list l11:level1
  574. {mso-level-number-format:bullet;
  575. mso-level-text:\F0B7;
  576. mso-level-tab-stop:36.0pt;
  577. mso-level-number-position:left;
  578. text-indent:-18.0pt;
  579. mso-ansi-font-size:10.0pt;
  580. font-family:Symbol;}
  581. ol
  582. {margin-bottom:0cm;}
  583. ul
  584. {margin-bottom:0cm;}
  585. -->
  586. </style>
  587. <!--[if gte mso 10]>
  588. <style>
  589. /* Style Definitions */
  590. table.MsoNormalTable
  591. {mso-style-name:"Table Normal";
  592. mso-tstyle-rowband-size:0;
  593. mso-tstyle-colband-size:0;
  594. mso-style-noshow:yes;
  595. mso-style-parent:"";
  596. mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
  597. mso-para-margin:0cm;
  598. mso-para-margin-bottom:.0001pt;
  599. mso-pagination:widow-orphan;
  600. font-size:10.0pt;
  601. font-family:"Times New Roman";
  602. mso-ansi-language:#0400;
  603. mso-fareast-language:#0400;
  604. mso-bidi-language:#0400;}
  605. </style>
  606. <![endif]--><!--[if gte mso 9]><xml>
  607. <o:shapedefaults v:ext="edit" spidmax="1026"/>
  608. </xml><![endif]--><!--[if gte mso 9]><xml>
  609. <o:shapelayout v:ext="edit">
  610. <o:idmap v:ext="edit" data="1"/>
  611. </o:shapelayout></xml><![endif]-->
  612. </head>
  613. <body bgcolor=white lang=EN-US link=blue vlink=blue style='tab-interval:36.0pt'>
  614. <div class=Section1>
  615. <h2>ADOdb Library for PHP</h2>
  616. <p>v5.20.3 01-Jan-2016<br>
  617. &copy; 2000-2013 John Lim (jlim#natsoft.com)<br>
  618. &copy; 2014 Damien Regad, Mark Newnham and the ADOdb community</p>
  619. <p><span style='font-size:7.5pt'>This software is dual licensed using BSD-Style
  620. and LGPL. This means you can use it in compiled proprietary and commercial
  621. products.</span></p>
  622. <p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
  623. &nbsp; <a href="http://adodb.sourceforge.net/#docs">Other Docs</a> </p>
  624. <p><a href="#intro"><b>Introduction</b></a><b><br>
  625. <a href="#features">Unique Features</a><br>
  626. <a href="#users">How People are using ADOdb</a><br>
  627. <a href="#bugs">Feature Requests and Bug Reports</a><br>
  628. <a href="#install">Installation</a><br>
  629. <a href="#mininstall">Minimum Install</a><br>
  630. <a href="#coding">Initializing Code and Connectioning to Databases</a><br>
  631. </b><span style='font-size:10.0pt'>&nbsp; <a href="#dsnsupport">Data Source
  632. Name (DSN) Support</a></span> &nbsp; <a href="#connect_ex">Connection Examples</a>
  633. <br>
  634. <b><a href="#speed">High Speed ADOdb - tuning tips</a></b><br>
  635. <b><a href="#hack">Hacking and Modifying ADOdb Safely</a><br>
  636. <a href="#php5">PHP5 Features</a></b><br>
  637. <span style='font-size:10.0pt'><a href="#php5iterators">foreach iterators</a> <a
  638. href="#php5exceptions">exceptions</a></span><br>
  639. <b><a href="#drivers">Supported Databases</a></b><br>
  640. <b><a href="#quickstart">Tutorials</a></b><br>
  641. <a href="#ex1">Example 1: Select</a><br>
  642. <a href="#ex2">Example 2: Advanced Select</a><br>
  643. <a href="#ex3">Example 3: Insert</a><br>
  644. <a href="#ex4">Example 4: Debugging</a> &nbsp;<a href="#exrs2html">rs2html
  645. example</a><br>
  646. <a href="#ex5">Example 5: MySQL and Menus</a><br>
  647. <a href="#ex6">Example 6: Connecting to Multiple Databases at once</a> <br>
  648. <a href="#ex7">Example 7: Generating Update and Insert SQL</a> <br>
  649. <a href="#ex8">Example 8: Implementing Scrolling with Next and Previous</a><br>
  650. <a href="#ex9">Example 9: Exporting in CSV or Tab-Delimited Format</a> <br>
  651. <a href="#ex10">Example 10: Custom filters</a><br>
  652. <a href="#ex11">Example 11: Smart Transactions</a><br>
  653. <br>
  654. <b><a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br>
  655. <a href="#DSN">Data Source Names</a><br>
  656. <a href="#caching">Caching</a></b><br>
  657. &nbsp; &nbsp; <a href="#memcache">MemCache</a><br>
  658. &nbsp; &nbsp; <a href="#cacheapi">Caching API</a><br>
  659. <b><a href="#pivot">Pivot Tables</a></b> </p>
  660. <p><a href="#ref"><b>REFERENCE</b></a> </p>
  661. <p><span style='font-size:10.0pt'>Variables: <a href="#adodb_countrecs">$ADODB_COUNTRECS</a>
  662. <a href="#adodb_ansi_padding_off">$ADODB_ANSI_PADDING_OFF</a> <a
  663. href="#adodb_cache_dir">$ADODB_CACHE_DIR</a> <br>
  664. &nbsp; &nbsp; &nbsp; &nbsp; <a href="#force_type">$ADODB_FORCE_TYPE</a> <a
  665. href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a> <a href="#adodb_lang">$ADODB_LANG</a>
  666. <a href="#adodb_auto_quote">ADODB_QUOTE_FIELDNAMES</a> <br>
  667. Constants: <a href="#adodb_assoc_case">ADODB_ASSOC_CASE</a> </span><br>
  668. <a href="#ADOConnection"><b>ADOConnection</b></a><br>
  669. <span style='font-size:10.0pt'>Connections: <a href="#connect">Connect</a> <a
  670. href="#pconnect">PConnect</a> <a href="#nconnect">NConnect</a> <a
  671. href="#isconnected">IsConnected</a><br>
  672. Executing SQL: <a href="#execute">Execute</a> <a href="#cacheexecute"><i>CacheExecute</i></a>
  673. <a href="#selectlimit">SelectLimit</a> <a href="#cacheSelectLimit"><i>CacheSelectLimit</i></a>
  674. <a href="#param">Param</a> <a href="#prepare">Prepare</a> <a href="#preparesp">PrepareSP</a>
  675. <a href="#inparameter">InParameter</a> <a href="#outparameter">OutParameter</a>
  676. <a href="#autoexecute">AutoExecute</a> <br>
  677. &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
  678. href="#getone">GetOne</a> <a href="#cachegetone"><i>CacheGetOne</i></a> <a
  679. href="#getrow">GetRow</a> <a href="#cachegetrow"><i>CacheGetRow</i></a> <a
  680. href="#getall">GetAll</a> <a href="#cachegetall"><i>CacheGetAll</i></a> <a
  681. href="#getcol">GetCol</a> <a href="#cachegetcol"><i>CacheGetCol</i></a> <a
  682. href="#getassoc1">GetAssoc</a> <a href="#cachegetassoc"><i>CacheGetAssoc</i></a>
  683. <a href="#replace">Replace</a> <a href="#getmedian">GetMedian</a> <br>
  684. &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
  685. href="#executecursor">ExecuteCursor</a> (oci8 only)<br>
  686. Generates SQL strings: <a href="#getupdatesql">GetUpdateSQL</a> <a
  687. href="#getinsertsql">GetInsertSQL</a> <a href="#concat">Concat</a> <a
  688. href="#ifnull">IfNull</a> <a href="#length">length</a> <a href="#random">random</a>
  689. <a href="#substr">substr</a> <a href="#qstr">qstr</a> <a href="#param">Param</a>
  690. <a href="#OffsetDate">OffsetDate</a> <a href="#sqldate">SQLDate</a> <a
  691. href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a
  692. href="#binddate">BindDate</a> <a href="#bindtimestamp">BindTimeStamp</a> <br>
  693. Blobs: <a href="#updateblob">UpdateBlob</a> <a href="#updateclob">UpdateClob</a>
  694. <a href="#updateblobfile">UpdateBlobFile</a> <a href="#blobencode">BlobEncode</a>
  695. <a href="#blobdecode">BlobDecode</a><br>
  696. Paging/Scrolling: <a href="#pageexecute">PageExecute</a> <a
  697. href="#cachepageexecute">CachePageExecute</a><br>
  698. Cleanup: <a href="#cacheflush">CacheFlush</a> <a href="#Close">Close</a><br>
  699. Transactions: <a href="#starttrans">StartTrans</a> <a href="#completetrans">CompleteTrans</a>
  700. <a href="#failtrans">FailTrans</a> <a href="#hasfailedtrans">HasFailedTrans</a>
  701. <a href="#begintrans">BeginTrans</a> <a href="#committrans">CommitTrans</a> <a
  702. href="#rollbacktrans">RollbackTrans</a> <a href="#SetTransactionMode">SetTransactionMode</a><br>
  703. Fetching Data: <a href="#setfetchmode">SetFetchMode</a><br>
  704. Strings: <a href="#concat">concat</a> <a href="#length">length</a> <a
  705. href="#qstr">qstr</a> <a href="#quote">quote</a> <a href="#substr">substr</a><br>
  706. Dates: <a href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a
  707. href="#unixdate">UnixDate</a> <a href="#binddate">BindDate</a> <a
  708. href="#bindtimestamp">BindTimeStamp</a> <a href="#unixtimestamp">UnixTimeStamp</a>
  709. <a href="#OffsetDate">OffsetDate</a> <a href="#SQLDate">SQLDate</a> <br>
  710. Row Management: <a href="#affected_rows">Affected_Rows</a> <a
  711. href="#inserted_id">Insert_ID</a> <a href="#rowlock">RowLock</a> <a
  712. href="#genid">GenID</a> <a href="#createseq">CreateSequence</a> <a
  713. href="#dropseq">DropSequence</a> <br>
  714. Error Handling: <a href="#errormsg">ErrorMsg</a> <a href="#errorno">ErrorNo</a>
  715. <a href="#metaerror">MetaError</a> <a href="#metaerrormsg">MetaErrorMsg</a> <a
  716. href="#ignoreerrors">IgnoreErrors</a><br>
  717. Data Dictionary (metadata): <a href="#metadatabases">MetaDatabases</a> <a
  718. href="#metatables">MetaTables</a> <a href="#metacolumns">MetaColumns</a> <a
  719. href="#metacolumnames">MetaColumnNames</a> <a href="#metaprimarykeys">MetaPrimaryKeys</a>
  720. <a href="#metaforeignkeys">MetaForeignKeys</a> <a href="#serverinfo">ServerInfo</a> <a href="#setcharset">SetCharSet</a>
  721. <br>
  722. Statistics and Query-Rewriting: <a href="#logsql">LogSQL</a> <a
  723. href="#fnexecute">fnExecute and fnCacheExecute</a><br>
  724. Deprecated: <a href="#bind">Bind</a> <a href="#blankrecordset">BlankRecordSet</a>
  725. <a href="#parameter">Parameter</a></span> <a href="#adorecordSet"><b><br>
  726. ADORecordSet</b></a><br>
  727. <span style='font-size:10.0pt'>Returns one field: <a href="#fields">Fields</a><br>
  728. Returns one row:<a href="#fetchrow">FetchRow</a> <a href="#fetchinto">FetchInto</a>
  729. <a href="#fetchobject">FetchObject</a> <a href="#fetchnextobject">FetchNextObject</a>
  730. <a href="#fetchobj">FetchObj</a> <a href="#fetchnextobj">FetchNextObj</a> <a
  731. href="#getrowassoc">GetRowAssoc</a> <br>
  732. Returns all rows:<a href="#getarray">GetArray</a> <a href="#getrows">GetRows</a>
  733. <a href="#getassoc">GetAssoc</a><br>
  734. Scrolling:<a href="#move">Move</a> <a href="#movenext">MoveNext</a> <a
  735. href="#movefirst">MoveFirst</a> <a href="#movelast">MoveLast</a> <a
  736. href="#abspos">AbsolutePosition</a> <a href="#currentrow">CurrentRow</a> <a
  737. href="#atfirstpage">AtFirstPage</a> <a href="#atlastpage">AtLastPage</a> <a
  738. href="#absolutepage">AbsolutePage</a> <br>
  739. Menu generation:<a href="#getmenu">GetMenu</a> <a href="#getmenu2">GetMenu2</a><br>
  740. Dates:<a href="#userdate">UserDate</a> <a href="#usertimestamp">UserTimeStamp</a>
  741. <a href="#unixdate">UnixDate</a> <a href="#unixtimestamp">UnixTimeStamp<br>
  742. </a>Recordset Info:<a href="#recordcount">RecordCount</a> <a
  743. href="#po_recordcount">PO_RecordCount</a> <a href="#nextrecordset">NextRecordSet</a><br>
  744. Field Info:<a href="#fieldcount">FieldCount</a> <a href="#fetchfield">FetchField</a>
  745. <a href="#metatype">MetaType</a><br>
  746. Cleanup: <a href="#rsclose">Close</a></span> </p>
  747. <p><span style='font-size:10.0pt'><a href="#rs2html"><b>rs2html</b></a>&nbsp; <a
  748. href="#exrs2html">example</a></span><br>
  749. <a href="#adodiff">Differences between ADOdb and ADO</a><br>
  750. <a href="#driverguide"><b>Database Driver Guide<br>
  751. </b></a><b><a href="#changes">Change Log</a></b></p>
  752. <h2>Introduction<a name=intro></a></h2>
  753. <p>PHP's database access functions are not standardised. This creates a need
  754. for a database class library to hide the differences between the different
  755. database API's (encapsulate the differences) so we can easily switch databases.
  756. PHP 4.0.5 or later is now required (because we use array-based str_replace).</p>
  757. <p>We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL
  758. Anywhere, Informix, PostgreSQL, FrontBase, SQLite, Interbase (Firebird and
  759. Borland variants), Foxpro, Access, <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>,
  760. DB2, SAP DB and ODBC. We have had successful reports of connecting to Progress
  761. and CacheLite via ODBC. We hope more people will contribute drivers to support
  762. other databases.</p>
  763. <p>PHP4 supports session variables. You can store your session information
  764. using ADOdb for true portability and scalability. See adodb-session.php for
  765. more information.</p>
  766. <p>Also read <a href="http://adodb.sourceforge.net/tips_portable_sql.htm">tips_portable_sql.htm</a>
  767. for tips on writing portable SQL.</p>
  768. <h2>Unique Features of ADOdb<a name=features></a></h2>
  769. <ul type=disc>
  770. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  771. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Easy for Windows
  772. programmers</b> to adapt to because many of the conventions are similar to
  773. Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>.</li>
  774. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  775. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'>Unlike other PHP database
  776. classes which focus only on select statements, <b>we provide support code
  777. to handle inserts and updates which can be adapted to multiple databases
  778. quickly.</b> Methods are provided for date handling, string concatenation
  779. and string quoting characters for differing databases.</li>
  780. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  781. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'>A<b> metatype system </b>is
  782. built in so that we can figure out that types such as CHAR, TEXT and
  783. STRING are equivalent in different databases.</li>
  784. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  785. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Easy to port</b> because
  786. all the database dependant code are stored in stub functions. You do not
  787. need to port the core logic of the classes.</li>
  788. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  789. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Portable table and index
  790. creation</b> with the <a href="docs-datadict.htm">datadict</a> classes. </li>
  791. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  792. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Database performance
  793. monitoring and SQL tuning</b> with the <a href="docs-perf.htm">performance
  794. monitoring</a> classes. </li>
  795. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  796. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Database-backed sessions</b>
  797. with the <a href="docs-session.htm">session management</a> classes.
  798. Supports session expiry notification. </li>
  799. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  800. mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Object-Relational
  801. Mapping</b> using <a href="docs-active-record.htm">ADOdb_Active_Record</a>
  802. classes. </li>
  803. </ul>
  804. <h2>How People are using ADOdb<a name=users></a></h2>
  805. <p class=MsoNormal>Here are some examples of how people are using ADOdb</p>
  806. <ul type=disc>
  807. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  808. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  809. href="http://phplens.com/">PhpLens</a> is a commercial data grid component
  810. that allows both cool Web designers and serious unshaved programmers to
  811. develop and maintain databases on the Web easily. Developed by the author
  812. of ADOdb.</li>
  813. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  814. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  815. href="http://www.interaktonline.com/Products/Free-Products/PHAkt/EOL/">PHAkt: PHP Extension for DreamWeaver
  816. Ultradev</a> allows you to script PHP in the popular Web page editor.
  817. Database handling provided by ADOdb.</li>
  818. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  819. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  820. href="http://www.andrew.cmu.edu/user/rdanyliw/snort/snortacid.html">Analysis
  821. Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to
  822. search and process a database of security incidents generated by
  823. security-related software such as IDSes and firewalls (e.g. Snort,
  824. ipchains). By Roman Danyliw.</li>
  825. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  826. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  827. href="http://www.postnuke.com/">PostNuke</a> is a very popular free
  828. content management system and weblog system. It offers full CSS support,
  829. HTML 4.01 transitional compliance throughout, an advanced blocks system,
  830. and is fully multi-lingual enabled. </li>
  831. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  832. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  833. href="http://www.escio.no/index.php?page_id=3&lang_id=2">EasyPublish
  834. CMS</a> is another free content management system for managing information
  835. and integrated modules on your internet, intranet- and extranet-sites.
  836. From <st1:country-region w:st="on"><st1:place w:st="on">Norway</st1:place></st1:country-region>.</li>
  837. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  838. mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
  839. href="http://www.nolapro.com/nolapro.html">NOLA</a> is a full featured accounting,
  840. inventory, and job tracking application. It is licensed under the GPL, and
  841. developed by Noguska. </li>
  842. </ul>
  843. <h2>Feature Requests and Bug Reports<a name=bugs></a></h2>
  844. <p>Feature requests and bug reports should be submitted on
  845. <a href="https://github.com/ADOdb/ADOdb/issues">Github</a>.
  846. </p>
  847. <p>Bug fixes and enhancements can be submitted as
  848. <a href="https://github.com/ADOdb/ADOdb/pulls">Pull Requests</a>.
  849. </p>
  850. <h2>Installation Guide<a name=install></a></h2>
  851. <p>Make sure you are running PHP 4.0.5 or later. Unpack all the files into a
  852. directory accessible by your webserver.</p>
  853. <p>To test, try modifying some of the tutorial examples. Make sure you
  854. customize the connection settings correctly. You can debug using <i>$db-&gt;debug
  855. = true</i> as shown below:</p>
  856. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  857. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  858. style='background:#EEEEEE'>&lt;?php<br>
  859. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>include('adodb/adodb.inc.php');<br>
  860. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = <a href="#adonewconnection">ADONewConnection</a>($dbdriver); # eg 'mysql' or 'postgres'<br>
  861. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;debug = true;<br>
  862. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;<a href="#connect">Connect</a>($server, $user, $password, $database);<br>
  863. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $db-&gt;<a href="#execute">Execute</a>('select * from some_small_table');<br>
  864. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print &quot;&lt;pre&gt;&quot;;<br>
  865. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs-&gt;<a href="#getrows">GetRows</a>());<br>
  866. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print &quot;&lt;/pre&gt;&quot;;<br>
  867. ?&gt;</pre></div>
  868. <h3>Minimum Install<a name=mininstall></a></h3>
  869. <p>For developers who want to release a minimal install of ADOdb, you will
  870. need: </p>
  871. <ul type=disc>
  872. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  873. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb.inc.php </li>
  874. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  875. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-lib.inc.php </li>
  876. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  877. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-time.inc.php </li>
  878. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  879. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>drivers/adodb-$database.inc.php
  880. </li>
  881. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  882. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>license.txt (for legal
  883. reasons) </li>
  884. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  885. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-php4.inc.php </li>
  886. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  887. mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-iterator.inc.php
  888. (php5 functionality) </li>
  889. </ul>
  890. <p class=MsoNormal>Optional: </p>
  891. <ul type=disc>
  892. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  893. mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-error.inc.php and
  894. lang/adodb-$lang.inc.php (if you use MetaError()) </li>
  895. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  896. mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-csvlib.inc.php (if
  897. you use cached recordsets - CacheExecute(), etc) </li>
  898. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  899. mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-exceptions.inc.php
  900. and adodb-errorhandler.inc.php (if you use adodb error handler or php5
  901. exceptions). </li>
  902. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  903. mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-active-record.inc.php
  904. if you use <a href="docs-active-record.htm">Active Records</a>. </li>
  905. </ul>
  906. <h3>Code Initialization Examples<a name=coding></a></h3>
  907. <p>When running ADOdb, at least two files are loaded. First is
  908. adodb/adodb.inc.php, which contains all functions used by all database classes.
  909. The code specific to a particular database is in the
  910. adodb/driver/adodb-????.inc.php file.</p>
  911. <p><a name=adonewconnection></a>For example, to connect to a mysql database:</p>
  912. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  913. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  914. style='background:#EEEEEE'>include('/path/to/set/here/adodb.inc.php');<br>
  915. $conn = &amp;ADONewConnection('mysql');</pre></div>
  916. <p>Whenever you need to connect to a database, you create a Connection object
  917. using the <b>ADONewConnection</b>($driver) function. <b>NewADOConnection</b>($driver)
  918. is an alternative name for the same function.</p>
  919. <p>At this point, you are not connected to the database (no longer true if you
  920. pass in a <a href="#dsnsupport">dsn</a>). You will first need to decide whether
  921. to use <i>persistent</i> or <i>non-persistent</i> connections. The advantage of
  922. <i>persistent</i> connections is that they are faster, as the database
  923. connection is never closed (even when you call Close()). <i>Non-persistent </i>connections
  924. take up much fewer resources though, reducing the risk of your database and
  925. your web-server becoming overloaded. </p>
  926. <p>For persistent connections, use $conn-&gt;<a href="#pconnect">PConnect()</a>,
  927. or $conn-&gt;<a href="#connect">Connect()</a> for non-persistent connections.
  928. Some database drivers also support <a href="#nconnect">NConnect()</a>, which
  929. forces the creation of a new connection. <a name="connection_gotcha"></a></p>
  930. <p><b>Connection Gotcha</b>: If you create two connections, but both use the
  931. same userid and password, PHP will share the same connection. This can cause
  932. problems if the connections are meant to different databases. The solution is
  933. to always use different userid's for different databases, or use NConnect(). <a
  934. name=dsnsupport></a></p>
  935. <h3>Data Source Name (DSN) Support</h3>
  936. <p>Since ADOdb 4.51, you can connect to a database by passing a dsn to
  937. NewADOConnection() (or ADONewConnection, which is the same function). The dsn
  938. format is: </p>
  939. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  940. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  941. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$driver://$username:$password@hostname/$database?options[=value]</pre></div>
  942. <p>NewADOConnection() calls Connect() or PConnect() internally for you. If the
  943. connection fails, false is returned. </p>
  944. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  945. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  946. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:green'># non-persistent connection</span></pre><pre><span
  947. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'mysql://root:pwd@localhost/mydb'; </pre><pre><span
  948. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = NewADOConnection($dsn);</pre><pre><span
  949. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (!$db) die(&quot;Connection failed&quot;);<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span></pre><pre><span
  950. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  951. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:green'># no need to call connect/pconnect!</span></pre><pre><span
  952. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$arr = $db-&gt;GetArray(&quot;select * from table&quot;);</pre><pre><span
  953. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  954. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:green'># persistent connection</span></pre>
  955. <pre><span
  956. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn2 = 'mysql://root:pwd@localhost/mydb?persist';
  957. <span
  958. style='mso-tab-count:1'></span></pre>
  959. <pre><span style='mso-tab-count:
  960. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:green'># non-persistent connection on port 3000</span></pre>
  961. <pre><span
  962. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn2 = 'mysqli://root:pwd@localhost/mydb?persist=0&amp;port=3000';</pre>
  963. </div>
  964. <p>If you have special characters such as /:?_ in your dsn, then you need to
  965. rawurlencode them first: </p>
  966. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  967. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  968. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$pwd = rawurlencode($pwd);<br>
  969. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = &quot;mysql://root:$pwd@localhost/mydb&quot;;</pre><pre
  970. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn2=rawurlencode(&quot;sybase_ase&quot;).&quot;://user:pass@host/path?query&quot;;</pre></div>
  971. <p>Legal options are: </p>
  972. <div align=center>
  973. <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt'>
  974. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  975. <td style='padding:.75pt .75pt .75pt .75pt'>
  976. <p class=MsoNormal>For all drivers</p>
  977. </td>
  978. <td style='padding:.75pt .75pt .75pt .75pt'>
  979. <p class=MsoNormal>'persist', 'persistent', 'debug', 'fetchmode', 'new' , 'cachesecs', 'memcache'</p>
  980. </td>
  981. </tr>
  982. <tr style='mso-yfti-irow:1'>
  983. <td style='padding:.75pt .75pt .75pt .75pt'>
  984. <p class=MsoNormal>Interbase/Firebird </p>
  985. </td>
  986. <td style='padding:.75pt .75pt .75pt .75pt'>
  987. <p class=MsoNormal>'dialect','charset','buffers','role' </p>
  988. </td>
  989. </tr>
  990. <tr style='mso-yfti-irow:2'>
  991. <td style='padding:.75pt .75pt .75pt .75pt'>
  992. <p class=MsoNormal>M'soft <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City></p>
  993. </td>
  994. <td style='padding:.75pt .75pt .75pt .75pt'>
  995. <p class=MsoNormal>'charpage' </p>
  996. </td>
  997. </tr>
  998. <tr style='mso-yfti-irow:3'>
  999. <td style='padding:.75pt .75pt .75pt .75pt'>
  1000. <p class=MsoNormal>MySQL</p>
  1001. </td>
  1002. <td style='padding:.75pt .75pt .75pt .75pt'>
  1003. <p class=MsoNormal>'clientflags' </p>
  1004. </td>
  1005. </tr>
  1006. <tr style='mso-yfti-irow:4'>
  1007. <td style='padding:.75pt .75pt .75pt .75pt'>
  1008. <p class=MsoNormal>MySQLi</p>
  1009. </td>
  1010. <td style='padding:.75pt .75pt .75pt .75pt'>
  1011. <p class=MsoNormal>'port', 'socket', 'clientflags' </p>
  1012. </td>
  1013. </tr>
  1014. <tr style='mso-yfti-irow:5;mso-yfti-lastrow:yes'>
  1015. <td style='padding:.75pt .75pt .75pt .75pt'>
  1016. <p class=MsoNormal>Oci8</p>
  1017. </td>
  1018. <td style='padding:.75pt .75pt .75pt .75pt'>
  1019. <p class=MsoNormal>'nls_date_format','charset' </p>
  1020. </td>
  1021. </tr>
  1022. </table>
  1023. </div>
  1024. <p>For all drivers, when the options <i>persist</i> or <i>persistent</i> are
  1025. set, a persistent connection is forced; similarly, when <i>new</i> is set, then
  1026. a new connection will be created using NConnect if the underlying driver
  1027. supports it. The <i>debug</i> option enables debugging. The <i>fetchmode</i>
  1028. calls <a href="#setfetchmode">SetFetchMode()</a>. If no value is defined for an
  1029. option, then the value is set to 1. </p>
  1030. <p>Since ADOdb 5.09, we added 2 new parameters:</p>
  1031. <ul>
  1032. <li class=MsoNormal><i>cachesecs</i> which globally determines how many seconds to cache recordsets (default is 3600 secs if not defined) when
  1033. CacheExecute() and CacheSelectLimit() are called and no cache-time parameter is passed into these functions.
  1034. <li class=MsoNormal><i>memcache</i> which defines the memcache host, port and whether to use compression. For example:
  1035. <pre>
  1036. # we have a memcache server at 10.1.1.22 using default port 11211, no compression
  1037. $dsn = 'mysql://user:pwd@localhost/mydb?memcache=10.1.1.22';
  1038. # we have a memcache server 10.1.1.22 port 8888, compression=on
  1039. $dsn = 'mysql://user:pwd@localhost/mydb?memcache=10.1.1.22:8888:1';
  1040. # we have a memcache servers mem1,mem2 on port 8888, compression=off
  1041. $dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0';
  1042. # we have a memcache servers mem1,mem2 on port 8888, compression=off and cachesecs=120
  1043. $dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0&cachesecs=120';
  1044. </pre>
  1045. </ul>
  1046. <p>ADOdb DSN's are compatible with version 1.0 of PEAR DB's DSN format. <a
  1047. name="connect_ex"></a></p>
  1048. <h3><span style='mso-bookmark:connect_ex'>Examples of Connecting to Databases</span></h3>
  1049. <h4><span style='mso-bookmark:connect_ex'>MySQL and Most Other Database Drivers</span></h4>
  1050. <p><span style='mso-bookmark:connect_ex'>MySQL connections are very
  1051. straightforward, and the parameters are identical to mysql_connect:</span></p>
  1052. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1053. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1054. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = &amp;ADONewConnection('mysql'); <br>
  1055. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('localhost','userid','password','database');<br>
  1056. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1057. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style='mso-bookmark:
  1058. connect_ex'><span style='color:green'># or dsn </span></span></pre><pre><span
  1059. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'mysql://user:pwd@localhost/mydb'; </span></pre><pre><span
  1060. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for Connect()</span></pre><pre><span
  1061. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></pre><pre><span
  1062. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span
  1063. style='mso-bookmark:connect_ex'><span style='color:green'># or persistent dsn</span></span></pre><pre><span
  1064. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'mysql://user:pwd@localhost/mydb?persist'; </span></pre><pre><span
  1065. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for PConnect()</span></pre><pre><span
  1066. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></pre><pre><span
  1067. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span
  1068. style='mso-bookmark:connect_ex'><span style='color:green'># a more complex example:</span></span></pre><pre><span
  1069. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$pwd = urlencode($pwd);</span></pre><pre><span
  1070. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$flags =<span style='mso-spacerun:yes'>&nbsp; </span>MYSQL_CLIENT_COMPRESS;</span></pre><pre><span
  1071. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = &quot;mysql://user:$pwd@localhost/mydb?persist&amp;clientflags=$flags&quot;;</span></pre><pre><span
  1072. style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for PConnect()</span></pre><pre
  1073. style='background:#EEEEEE'><span style='mso-bookmark:connect_ex'> </span></pre></div>
  1074. <p><span style='mso-bookmark:connect_ex'>For most drivers, you can use the
  1075. standard function: Connect($server, $user, $password, $database), or a </span><a
  1076. href="dsnsupport">DSN</a> since ADOdb 4.51. Exceptions to this are listed
  1077. below. </p>
  1078. <h4><a name=pdo>PDO</a></h4>
  1079. <p><span style='mso-bookmark:pdo'>PDO, which only works with PHP5, accepts a
  1080. driver specific connection string: </span></p>
  1081. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1082. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1083. style='mso-bookmark:pdo'><o:p>&nbsp;</o:p></span></pre><pre><span
  1084. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn =&amp; NewADConnection('pdo');</span></pre><pre><span
  1085. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect('mysql:host=localhost',$user,$pwd,$mydb);</span></pre><pre><span
  1086. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect('mysql:host=localhost;dbname=mydb',$user,$pwd);</span></pre><pre><span
  1087. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(&quot;mysql:host=localhost;dbname=mydb;username=$user;password=$pwd&quot;);</span></pre></div>
  1088. <p><span style='mso-bookmark:pdo'>The DSN mechanism is also supported: </span></p>
  1089. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1090. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1091. style='mso-bookmark:pdo'><o:p>&nbsp;</o:p></span></pre><pre><span
  1092. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn =&amp; NewADConnection(&quot;pdo_mysql://user:pwd@localhost/mydb?persist&quot;); # persist is optional</span></pre></div>
  1093. <h4><span style='mso-bookmark:pdo'>PostgreSQL</span></h4>
  1094. <p><span style='mso-bookmark:pdo'>PostgreSQL 7 and 8 accepts connections using:
  1095. </span></p>
  1096. <p><span style='mso-bookmark:pdo'>a. the standard connection string:</span></p>
  1097. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1098. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1099. style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
  1100. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = &amp;ADONewConnection('postgres');<span style='mso-spacerun:yes'>&nbsp; </span><br>
  1101. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('host=localhost port=5432 dbname=mary');</span></pre></div>
  1102. <p><span style='mso-bookmark:pdo'>b. the classical 4 parameters:</span></p>
  1103. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1104. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1105. style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
  1106. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('localhost','userid','password','database');<br>
  1107. <span style='mso-spacerun:yes'>&nbsp;</span></span></pre></div>
  1108. <p><span style='mso-bookmark:pdo'>c. dsn: </span></p>
  1109. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1110. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1111. style='mso-bookmark:pdo'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'postgres://user:pwd@localhost/mydb?persist';<span style='mso-spacerun:yes'>&nbsp; </span># persist is optional</span></pre><pre
  1112. style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
  1113. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for Connect/PConnect</span></pre></div>
  1114. <span style='mso-bookmark:pdo'></span>
  1115. <h4><a name=ldap></a>LDAP</h4>
  1116. <p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for
  1117. the driver and this example: </p>
  1118. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1119. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre>require('/path/to/adodb.inc.php');</pre><pre><o:p>&nbsp;</o:p></pre><pre>/* Make sure to set this BEFORE calling Connect() */</pre><pre>$LDAP_CONNECT_OPTIONS = Array(</pre><pre><span
  1120. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_DEREF, &quot;OPTION_VALUE&quot;=&gt;2),</pre><pre><span
  1121. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_SIZELIMIT,&quot;OPTION_VALUE&quot;=&gt;100),</pre><pre><span
  1122. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_TIMELIMIT,&quot;OPTION_VALUE&quot;=&gt;30),</pre><pre><span
  1123. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_PROTOCOL_VERSION,&quot;OPTION_VALUE&quot;=&gt;3),</pre><pre><span
  1124. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_ERROR_NUMBER,&quot;OPTION_VALUE&quot;=&gt;13),</pre><pre><span
  1125. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_REFERRALS,&quot;OPTION_VALUE&quot;=&gt;FALSE),</pre><pre><span
  1126. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Array (&quot;OPTION_NAME&quot;=&gt;LDAP_OPT_RESTART,&quot;OPTION_VALUE&quot;=&gt;FALSE)</pre><pre>);</pre><pre>$host = 'ldap.baylor.edu';</pre><pre>$ldapbase = 'ou=People,o=<st1:place
  1127. w:st="on"><st1:PlaceName w:st="on">Baylor</st1:PlaceName> <st1:PlaceType w:st="on">University</st1:PlaceType></st1:place>,c=US';</pre><pre><o:p>&nbsp;</o:p></pre><pre>$ldap = NewADOConnection( 'ldap' );</pre><pre>$ldap-&gt;Connect( $host, $user_name='', $password='', $ldapbase );</pre><pre><o:p>&nbsp;</o:p></pre><pre>echo &quot;&lt;pre&gt;&quot;;</pre><pre><o:p>&nbsp;</o:p></pre><pre>print_r( $ldap-&gt;ServerInfo() );</pre><pre>$ldap-&gt;SetFetchMode(ADODB_FETCH_ASSOC);</pre><pre>$userName = 'eldridge';</pre><pre>$filter=&quot;(|(CN=$userName*)(sn=$userName*)(givenname=$userName*)(uid=$userName*))&quot;;</pre><pre><o:p>&nbsp;</o:p></pre><pre>$rs = $ldap-&gt;Execute( $filter );</pre><pre>if ($rs)</pre><pre><span
  1128. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>while ($arr = $rs-&gt;FetchRow()) {</pre><pre><span
  1129. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($arr);<span
  1130. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  1131. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</pre><pre><o:p>&nbsp;</o:p></pre><pre>$rs = $ldap-&gt;Execute( $filter );</pre><pre>if ($rs) </pre><pre><span
  1132. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>while (!$rs-&gt;EOF) {</pre><pre> <span
  1133. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs-&gt;fields);<span
  1134. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs-&gt;MoveNext();</pre><pre><span
  1135. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>} </pre><pre><span style='mso-tab-count:
  1136. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre>print_r( $ldap-&gt;GetArray( $filter ) );</pre><pre>print_r( $ldap-&gt;GetRow( $filter ) );</pre><pre><o:p>&nbsp;</o:p></pre><pre>$ldap-&gt;Close();</pre><pre>echo &quot;&lt;/pre&gt;&quot;;</pre></div>
  1137. <p>Using DSN: </p>
  1138. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1139. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre>$dsn = &quot;ldap://ldap.baylor.edu/ou=People,o=<st1:place
  1140. w:st="on"><st1:PlaceName w:st="on">Baylor</st1:PlaceName> <st1:PlaceType w:st="on">University</st1:PlaceType></st1:place>,c=US&quot;;</pre><pre>$db = NewADOConnection($dsn);</pre></div>
  1141. <h4>Interbase/Firebird</h4>
  1142. <p class=MsoNormal>You define the database in the $host parameter: </p>
  1143. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1144. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1145. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = &amp;ADONewConnection('ibase'); <br>
  1146. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');</pre></div>
  1147. <p>Or dsn: </p>
  1148. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1149. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1150. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'firebird://user:pwd@localhost/mydb?persist&amp;dialect=3';<span style='mso-spacerun:yes'>&nbsp; </span># persist is optional<br>
  1151. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for Connect/PConnect</pre></div>
  1152. <h4>SQLite</h4>
  1153. <p class=MsoNormal>Sqlite will create the database file if it does not exist. </p>
  1154. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1155. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1156. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = &amp;ADONewConnection('sqlite');</pre><pre
  1157. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist</pre></div>
  1158. <p>Or dsn: </p>
  1159. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1160. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1161. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$path = urlencode('c:\path\to\sqlite.db');</pre><pre><span
  1162. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = &quot;sqlite://$path/?persist&quot;;<span style='mso-spacerun:yes'>&nbsp; </span># persist is optional</pre><pre
  1163. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for Connect/PConnect</pre></div>
  1164. <h4>Oracle (oci8)</h4>
  1165. <p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
  1166. newer versions of the Oracle, eg. 9i and 10g.</p>
  1167. <p>a. PHP and Oracle reside on the same machine, use default SID.</p>
  1168. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1169. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1170. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(false, 'scott', 'tiger');</pre></div>
  1171. <p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS'</p>
  1172. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1173. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1174. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect(false, 'scott', 'tiger', 'myTNS');</pre></div>
  1175. <p>or</p>
  1176. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1177. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1178. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span><span
  1179. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;PConnect('myTNS', 'scott', 'tiger');</pre></div>
  1180. <p>c. Host Address and SID</p>
  1181. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1182. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  1183. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># with adodb 5.06 or 4.991 and later</pre><pre><span
  1184. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', &quot;SID=$SID&quot;);</pre><pre><span
  1185. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  1186. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># OR with all versions of ADOdb</pre><pre><span
  1187. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;connectSID = true;</pre><pre><span
  1188. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', $SID);</pre><pre
  1189. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre></div>
  1190. <p>d. Host Address and Service Name</p>
  1191. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1192. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1193. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre></div>
  1194. <p>e. Oracle connection string: </p>
  1195. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1196. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1197. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$cstr = &quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))<br>
  1198. <span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(CONNECT_DATA=(SID=$sid)))&quot;;<br>
  1199. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect($cstr, 'scott', 'tiger');</pre></div>
  1200. <p>f. ADOdb dsn: </p>
  1201. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1202. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1203. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'oci8://user:pwd@tnsname/?persist';<span style='mso-spacerun:yes'>&nbsp; </span># persist is optional<br>
  1204. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'>&nbsp; </span># no need for Connect/PConnect<br>
  1205. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1206. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'oci8://user:pwd@host/sid';<br>
  1207. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);<br>
  1208. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1209. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'oci8://user:pwd@/';<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># oracle on local machine<br>
  1210. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn = ADONewConnection($dsn);</pre></div>
  1211. <p>You can also set the charSet for Oracle 9.2 and later, supported since PHP
  1212. 4.3.2, ADOdb 4.54: </p>
  1213. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1214. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1215. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;charSet = 'we8iso8859p1';<br>
  1216. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(...);<br>
  1217. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1218. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># or<br>
  1219. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = 'oci8://user:pwd@tnsname/?charset=WE8MSWIN1252';<br>
  1220. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = ADONewConnection($dsn);</pre></div>
  1221. <h4><a name=dsnless></a>DSN-less ODBC ( Access, MSSQL and DB2 examples)</h4>
  1222. <p>ODBC DSN's can be created in the ODBC control panel, or you can use a
  1223. DSN-less connection.To use DSN-less connections with ODBC you need PHP 4.3 or
  1224. later. </p>
  1225. <p>For Microsoft Access:</p>
  1226. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1227. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  1228. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db =&amp; ADONewConnection('access');<br>
  1229. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = <strong><span
  1230. style='font-family:"Courier New"'>&quot;Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\\northwind.mdb;Uid=Admin;Pwd=;&quot;;</span></strong></pre><pre><span
  1231. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect($dsn);</pre></div>
  1232. <p class=MsoNormal>For Microsoft SQL Server: </p>
  1233. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1234. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1235. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db =&amp; ADONewConnection('odbc_mssql');<br>
  1236. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = <strong><span
  1237. style='font-family:"Courier New"'>&quot;Driver={SQL Server};Server=localhost;Database=northwind;&quot;</span></strong>;<br>
  1238. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect($dsn,'userid','password');</pre></div>
  1239. <p class=MsoNormal>or if you prefer to use the mssql extension (which is
  1240. limited to mssql 6.5 functionality): </p>
  1241. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1242. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1243. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db =&amp; ADONewConnection('mssql');<br>
  1244. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute('localhost', 'userid', 'password', 'northwind');</pre></div>
  1245. <p class=MsoNormal>For DB2: </p>
  1246. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1247. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  1248. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dbms = 'db2'; # or 'odbc_db2' if db2 extension not available</pre><pre><span
  1249. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db =&amp; ADONewConnection($dbms);</pre><pre><span
  1250. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$dsn = &quot;driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP;&quot;.</pre><pre><span
  1251. style='mso-tab-count:4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;uid=root; pwd=secret&quot;;<br>
  1252. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect($dsn);<br>
  1253. # or connect and set schema
  1254. $db-&gt;Connect($dsn,null,null,$schema);</pre>
  1255. </div>
  1256. <p class=MsoNormal><b>DSN-less Connections with <st1:City w:st="on">ADO</st1:City></b><br>
  1257. If you are using versions of PHP earlier than PHP 4.3.0, DSN-less connections
  1258. only work with Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>,
  1259. which is Microsoft's COM based API. An example using the ADOdb library and
  1260. Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>:
  1261. </p>
  1262. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1263. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?php<br>
  1264. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>include('adodb.inc.php'); <br>
  1265. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = &amp;ADONewConnection(&quot;ado_mssql&quot;);<br>
  1266. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print &quot;&lt;h1&gt;Connecting DSN-less $db-&gt;databaseType...&lt;/h1&gt;&quot;;<br>
  1267. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1268. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>$myDSN=&quot;PROVIDER=MSDASQL;DRIVER={SQL Server};&quot;<br>
  1269. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>. &quot;SERVER=flipper;DATABASE=ai;UID=sa;PWD=;&quot;<span style='mso-spacerun:yes'>&nbsp; </span>;</b></pre><pre><span
  1270. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect($myDSN);</pre><pre><span
  1271. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  1272. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $db-&gt;Execute(&quot;select * from table&quot;);</pre><pre><span
  1273. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$arr = $rs-&gt;GetArray();</pre><pre><span
  1274. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($arr);</pre><pre>?&gt;</pre></div>
  1275. <h2><a name=speed></a>High Speed ADOdb - tuning tips</h2>
  1276. <p>ADOdb is a big class library, yet it <a href="http://phplens.com/lens/adodb/">consistently
  1277. beats</a> all other PHP class libraries in performance. This is because it is
  1278. designed in a layered fashion, like an onion, with the fastest functions in the
  1279. innermost layer. Stick to the following functions for best performance:</p>
  1280. <div align=center>
  1281. <table class=MsoNormalTable border=1 cellpadding=0 width="40%"
  1282. style='width:40.0%;mso-cellspacing:1.5pt'>
  1283. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  1284. <td style='padding:.75pt .75pt .75pt .75pt'>
  1285. <p class=MsoNormal align=center style='text-align:center'><b>Innermost Layer</b></p>
  1286. </td>
  1287. </tr>
  1288. <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
  1289. <td style='padding:.75pt .75pt .75pt .75pt'>
  1290. <p align=center style='text-align:center'>Connect, PConnect, NConnect<br>
  1291. Execute, CacheExecute<br>
  1292. SelectLimit, CacheSelectLimit<br>
  1293. MoveNext, Close <br>
  1294. qstr, Affected_Rows, Insert_ID</p>
  1295. </td>
  1296. </tr>
  1297. </table>
  1298. </div>
  1299. <p>The fastest way to access the field data is by accessing the array
  1300. $recordset-&gt;fields directly. Also set the global variables <a
  1301. href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a> = ADODB_FETCH_NUM, and (for
  1302. oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a>
  1303. = false before you connect to your database.</p>
  1304. <p>Consider using bind parameters if your database supports it, as it improves
  1305. query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
  1306. quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
  1307. <p>Lastly make sure you have a PHP accelerator cache installed such as APC,
  1308. Turck MMCache, Zend Accelerator or ionCube.</p>
  1309. <p>Some examples:</p>
  1310. <div align=center>
  1311. <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt'>
  1312. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  1313. <td style='padding:.75pt .75pt .75pt .75pt'>
  1314. <p class=MsoNormal><b>Fastest data retrieval using PHP</b></p>
  1315. </td>
  1316. <td style='padding:.75pt .75pt .75pt .75pt'>
  1317. <p class=MsoNormal><b>Fastest data retrieval using ADOdb extension</b></p>
  1318. </td>
  1319. </tr>
  1320. <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
  1321. <td style='padding:.75pt .75pt .75pt .75pt'>
  1322. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;
  1323. mso-border-alt:solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;
  1324. background:#EEEEEE'><pre style='background:#EEEEEE'>$rs =&amp; $rs-&gt;Execute($sql);<br>
  1325. while (!$rs-&gt;EOF) {<br>
  1326. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var_dump($rs-&gt;fields);<br>
  1327. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs-&gt;MoveNext();<br>
  1328. }</pre></div>
  1329. </td>
  1330. <td style='padding:.75pt .75pt .75pt .75pt'>
  1331. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;
  1332. mso-border-alt:solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;
  1333. background:#EEEEEE'><pre style='margin-bottom:12.0pt;background:#EEEEEE'>$rs =&amp; $rs-&gt;Execute($sql);<br>
  1334. $array = adodb_getall($rs);<br>
  1335. var_dump($array);<br style='mso-special-character:line-break'>
  1336. <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
  1337. <![endif]></pre></div>
  1338. </td>
  1339. </tr>
  1340. </table>
  1341. </div>
  1342. <p><b>Advanced Tips</b> </p>
  1343. <p>If you have the <a href="http://adodb.sourceforge.net/#extension">ADOdb C
  1344. extension</a> installed, you can replace your calls to $rs-&gt;MoveNext() with
  1345. adodb_movenext($rs). This doubles the speed of this operation. For retrieving
  1346. entire recordsets at once, use GetArray(), which uses the high speed extension
  1347. function adodb_getall($rs) internally. </p>
  1348. <p>Execute() is the default way to run queries. You can use the low-level
  1349. functions _Execute() and _query() to reduce query overhead. Both these
  1350. functions share the same parameters as Execute(). </p>
  1351. <p>If you do not have any bind parameters or your database supports binding
  1352. (without emulation), then you can call _Execute() directly. Calling this
  1353. function bypasses bind emulation. Debugging is still supported in _Execute(). </p>
  1354. <p>If you do not require debugging facilities nor emulated binding, and do not
  1355. require a recordset to be returned, then you can call _query. This is great for
  1356. inserts, updates and deletes. Calling this function bypasses emulated binding,
  1357. debugging, and recordset handling. Either the resultid, true or false are
  1358. returned by _query(). </p>
  1359. <p>For Informix, you can disable scrollable cursors with $db-&gt;cursorType =
  1360. 0. </p>
  1361. <h2><a name=hack></a>Hacking ADOdb Safely</h2>
  1362. <p>You might want to modify ADOdb for your own purposes. Luckily you can still
  1363. maintain backward compatibility by sub-classing ADOdb and using the
  1364. $ADODB_NEWCONNECTION variable. $ADODB_NEWCONNECTION allows you to override the
  1365. behaviour of ADONewConnection(). ADOConnection() checks for this variable and
  1366. will call the function-name stored in this variable if it is defined. </p>
  1367. <p>In the following example, new functionality for the connection object is
  1368. placed in the <i>hack_mysql</i> and <i>hack_postgres7</i> classes. The
  1369. recordset class naming convention can be controlled using $rsPrefix. Here we
  1370. set it to 'hack_rs_', which will make ADOdb use <i>hack_rs_mysql</i> and <i>hack_rs_postgres7</i>
  1371. as the recordset classes. </p>
  1372. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1373. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  1374. style='background:#EEEEEE'>class hack_mysql extends adodb_mysql {<br>
  1375. var $rsPrefix = 'hack_rs_';<br>
  1376. <span style='mso-spacerun:yes'>&nbsp; </span>/* Your mods here */<br>
  1377. }<br>
  1378. <br>
  1379. class hack_rs_mysql extends ADORecordSet_mysql {<br>
  1380. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;</span>/* Your mods here */<br>
  1381. }<br>
  1382. <br>
  1383. class hack_postgres7 extends adodb_postgres7 {<br>
  1384. var $rsPrefix = 'hack_rs_';<br>
  1385. <span style='mso-spacerun:yes'>&nbsp; </span>/* Your mods here */<br>
  1386. }<br>
  1387. <br>
  1388. class hack_rs_postgres7 extends ADORecordSet_postgres7 {<br>
  1389. <span style='mso-spacerun:yes'>&nbsp;</span>/* Your mods here */<br>
  1390. }<br>
  1391. <br>
  1392. $ADODB_NEWCONNECTION = 'hack_factory';<br>
  1393. <br>
  1394. function&amp; hack_factory($driver)<br>
  1395. {<br>
  1396. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if ($driver !== 'mysql' &amp;&amp; $driver !== 'postgres7') return false;<br>
  1397. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  1398. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$driver = 'hack_'.$driver;<br>
  1399. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$obj = new $driver();<br>
  1400. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>return $obj;<br>
  1401. }<br>
  1402. <br>
  1403. include_once('adodb.inc.php');</pre></div>
  1404. <p>Don't forget to call the constructor of the parent class in your
  1405. constructor. If you want to use the default ADOdb drivers return false in the
  1406. above hack_factory() function. Also you can define your own
  1407. ADORecordSet_empty() class, by defining a class $$this-&gt;rsPrefix.'empty'
  1408. since 4.96/5.02. <a name=php5></a></p>
  1409. <h2>PHP5 Features</h2>
  1410. <p class=MsoNormal>ADOdb 4.02 or later will transparently determine which
  1411. version of PHP you are using. If PHP5 is detected, the following features become
  1412. available: </p>
  1413. <ul type=disc>
  1414. <li class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt;
  1415. mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><b>PDO</b>: PDO drivers
  1416. are available. See the <a href="#pdo">connection examples</a>. Currently
  1417. PDO drivers are not as powerful as native drivers, and should be treated
  1418. as experimental.<a name=php5iterators></a></li>
  1419. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  1420. mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><b>Foreach iterators</b>:
  1421. This is a very natural way of going through a recordset: </li>
  1422. </ul>
  1423. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1424. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE;
  1425. margin-left:36.0pt;margin-right:0cm'><pre style='background:#EEEEEE'><span
  1426. style='mso-tab-count:1'>&nbsp; </span>$ADODB_FETCH_MODE = ADODB_FETCH_NUM;<br>
  1427. <span style='mso-tab-count:1'>&nbsp; </span>$rs = $db-&gt;Execute($sql);<br>
  1428. <span style='mso-tab-count:1'>&nbsp; </span>foreach($rs as $k =&gt; $row) {<br>
  1429. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>echo &quot;r1=&quot;.$row[0].&quot; r2=&quot;.$row[1].&quot;&lt;br&gt;&quot;;<br>
  1430. <span style='mso-tab-count:1'>&nbsp; </span>}</pre></div>
  1431. <ul type=disc>
  1432. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  1433. mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><a name=php5exceptions></a><b>Exceptions</b>:
  1434. Just include <i>adodb-exceptions.inc.php</i> and you can now catch
  1435. exceptions on errors as they occur. </li>
  1436. </ul>
  1437. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  1438. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE;
  1439. margin-left:36.0pt;margin-right:0cm'><pre style='background:#EEEEEE'><span
  1440. style='mso-tab-count:1'>&nbsp; </span><b>include(&quot;../adodb-exceptions.inc.php&quot;);</b> <br>
  1441. <span style='mso-tab-count:1'>&nbsp; </span>include(&quot;../adodb.inc.php&quot;);<span
  1442. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span> <br>
  1443. <span style='mso-tab-count:1'>&nbsp; </span>try { <br>
  1444. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = NewADOConnection(&quot;oci8&quot;); <br>
  1445. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect('','scott','bad-password'); <br>
  1446. <span style='mso-tab-count:1'>&nbsp; </span>} catch (exception $e) { <br>
  1447. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var_dump($e); <br>
  1448. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>adodb_backtrace($e-&gt;gettrace());<br>
  1449. <span style='mso-tab-count:1'>&nbsp; </span>} </pre></div>
  1450. <p style='margin-left:36.0pt'>Note that reaching EOF is <b>not</b> considered
  1451. an error nor an exception. </p>
  1452. <h3><a name=drivers></a>Databases Supported</h3>
  1453. <p class=MsoNormal>The <i>name</i> below is the value you pass to
  1454. NewADOConnection($name) to create a connection object for that database. </p>
  1455. <table class=MsoNormalTable border=1 cellpadding=0 width="100%"
  1456. style='width:100.0%;mso-cellspacing:1.5pt'>
  1457. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  1458. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1459. <p class=MsoNormal><b>Name</b></p>
  1460. </td>
  1461. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1462. <p class=MsoNormal><b>Tested</b></p>
  1463. </td>
  1464. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1465. <p class=MsoNormal><b>Database</b></p>
  1466. </td>
  1467. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1468. <p class=MsoNormal><b><span style='font-size:10.0pt'>RecordCount() usable</span></b></p>
  1469. </td>
  1470. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1471. <p class=MsoNormal><b>Prerequisites</b></p>
  1472. </td>
  1473. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1474. <p class=MsoNormal><b>Operating Systems</b></p>
  1475. </td>
  1476. </tr>
  1477. <tr style='mso-yfti-irow:1'>
  1478. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1479. <p class=MsoNormal><b><span style='font-size:10.0pt'>access</span></b></p>
  1480. </td>
  1481. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1482. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1483. </td>
  1484. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1485. <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Access/Jet. You
  1486. need to create an ODBC DSN.</span></p>
  1487. </td>
  1488. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1489. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1490. </td>
  1491. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1492. <p class=MsoNormal><span style='font-size:10.0pt'>ODBC </span></p>
  1493. </td>
  1494. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1495. <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
  1496. </td>
  1497. </tr>
  1498. <tr style='mso-yfti-irow:2'>
  1499. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1500. <p class=MsoNormal><b><span style='font-size:10.0pt'>ado</span></b></p>
  1501. </td>
  1502. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1503. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1504. </td>
  1505. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1506. <p><span style='font-size:10.0pt'>Generic <st1:City w:st="on"><st1:place
  1507. w:st="on">ADO</st1:place></st1:City>, not tuned for specific databases.
  1508. Allows DSN-less connections. For best performance, use an OLEDB provider.
  1509. This is the base class for all ado drivers.</span></p>
  1510. <p><span style='font-size:10.0pt'>You can set $db-&gt;codePage before
  1511. connecting.</span></p>
  1512. </td>
  1513. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1514. <p class=MsoNormal><span style='font-size:10.0pt'>? depends on database</span></p>
  1515. </td>
  1516. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1517. <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
  1518. style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
  1519. style='font-size:10.0pt'> or OLEDB provider</span></p>
  1520. </td>
  1521. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1522. <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
  1523. </td>
  1524. </tr>
  1525. <tr style='mso-yfti-irow:3'>
  1526. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1527. <p class=MsoNormal><b><span style='font-size:10.0pt'>ado_access</span></b></p>
  1528. </td>
  1529. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1530. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1531. </td>
  1532. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1533. <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Access/Jet using <st1:City
  1534. w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>. Allows DSN-less
  1535. connections. For best performance, use an OLEDB provider.</span></p>
  1536. </td>
  1537. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1538. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1539. </td>
  1540. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1541. <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
  1542. style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
  1543. style='font-size:10.0pt'> or OLEDB provider</span></p>
  1544. </td>
  1545. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1546. <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
  1547. </td>
  1548. </tr>
  1549. <tr style='mso-yfti-irow:4'>
  1550. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1551. <p class=MsoNormal><b><span style='font-size:10.0pt'>ado_mssql</span></b></p>
  1552. </td>
  1553. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1554. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1555. </td>
  1556. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1557. <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft SQL Server using <st1:City
  1558. w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>. Allows DSN-less
  1559. connections. For best performance, use an OLEDB provider.</span></p>
  1560. </td>
  1561. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1562. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1563. </td>
  1564. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1565. <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
  1566. style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
  1567. style='font-size:10.0pt'> or OLEDB provider</span></p>
  1568. </td>
  1569. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1570. <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
  1571. </td>
  1572. </tr>
  1573. <tr style='mso-yfti-irow:5;height:40.5pt'>
  1574. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1575. <p class=MsoNormal><b><span style='font-size:10.0pt'>db2</span></b></p>
  1576. </td>
  1577. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1578. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1579. </td>
  1580. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1581. <p class=MsoNormal><span style='font-size:10.0pt'>Uses PHP's db2-specific
  1582. extension for better performance.</span></p>
  1583. </td>
  1584. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1585. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1586. </td>
  1587. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1588. <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
  1589. </td>
  1590. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1591. <p><span style='font-size:10.0pt'>Unix and Windows. Requires IBM DB2
  1592. Universal Database client.</span></p>
  1593. </td>
  1594. </tr>
  1595. <tr style='mso-yfti-irow:5;height:40.5pt'>
  1596. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1597. <p class=MsoNormal><b><span style='font-size:10.0pt'>db2oci</span></b></p>
  1598. </td>
  1599. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1600. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1601. </td>
  1602. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1603. <p class=MsoNormal><span style='font-size:10.0pt'>Based on db2 driver. Allows use of oracle style :0, :1, :2 bind variables. Used with DB2 9.7 or later with PL/SQL mode turned on.</span></p>
  1604. </td>
  1605. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1606. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1607. </td>
  1608. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1609. <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
  1610. </td>
  1611. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1612. <p><span style='font-size:10.0pt'>Unix and Windows. Requires IBM DB2
  1613. Universal Database client.</span></p>
  1614. </td>
  1615. </tr>
  1616. <tr style='mso-yfti-irow:6;height:40.5pt'>
  1617. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1618. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_db2</span></b></p>
  1619. </td>
  1620. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1621. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1622. </td>
  1623. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1624. <p class=MsoNormal><span style='font-size:10.0pt'>Connects to DB2 using
  1625. generic ODBC extension.</span></p>
  1626. </td>
  1627. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1628. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1629. </td>
  1630. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1631. <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
  1632. </td>
  1633. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  1634. <p><span style='font-size:10.0pt'>Unix and Windows. <a
  1635. href="http://www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix
  1636. install hints</a>. I have had reports that the $host and $database params
  1637. have to be reversed in Connect() when using the CLI interface.</span></p>
  1638. </td>
  1639. </tr>
  1640. <tr style='mso-yfti-irow:7'>
  1641. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1642. <p class=MsoNormal><b><span style='font-size:10.0pt'>vfp</span></b></p>
  1643. </td>
  1644. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1645. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1646. </td>
  1647. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1648. <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Visual FoxPro.
  1649. You need to create an ODBC DSN.</span></p>
  1650. </td>
  1651. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1652. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1653. </td>
  1654. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1655. <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
  1656. </td>
  1657. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1658. <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
  1659. </td>
  1660. </tr>
  1661. <tr style='mso-yfti-irow:8'>
  1662. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1663. <p class=MsoNormal><b><span style='font-size:10.0pt'>fbsql</span></b></p>
  1664. </td>
  1665. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1666. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1667. </td>
  1668. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1669. <p class=MsoNormal><span style='font-size:10.0pt'>FrontBase. </span></p>
  1670. </td>
  1671. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1672. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  1673. </td>
  1674. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1675. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  1676. </td>
  1677. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1678. <p><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1679. </td>
  1680. </tr>
  1681. <tr style='mso-yfti-irow:9'>
  1682. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1683. <p class=MsoNormal><b><span style='font-size:10.0pt'>ibase</span></b></p>
  1684. </td>
  1685. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1686. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  1687. </td>
  1688. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1689. <p class=MsoNormal><span style='font-size:10.0pt'>Interbase 6 or earlier.
  1690. Some users report you might need to use this<br>
  1691. $db-&gt;PConnect('localhost:c:/ibase/employee.gdb', &quot;sysdba&quot;,
  1692. &quot;masterkey&quot;) to connect. Lacks Affected_Rows currently.<br>
  1693. <br>
  1694. You can set $db-&gt;role, $db-&gt;dialect, $db-&gt;buffers and
  1695. $db-&gt;charSet before connecting.</span></p>
  1696. </td>
  1697. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1698. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1699. </td>
  1700. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1701. <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
  1702. </td>
  1703. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1704. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1705. </td>
  1706. </tr>
  1707. <tr style='mso-yfti-irow:10'>
  1708. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1709. <p class=MsoNormal><b><i><span style='font-size:10.0pt'>firebird</span></i></b></p>
  1710. </td>
  1711. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1712. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1713. </td>
  1714. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1715. <p class=MsoNormal><span style='font-size:10.0pt'>Firebird version of
  1716. interbase.</span></p>
  1717. </td>
  1718. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1719. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1720. </td>
  1721. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1722. <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
  1723. </td>
  1724. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1725. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1726. </td>
  1727. </tr>
  1728. <tr style='mso-yfti-irow:11'>
  1729. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1730. <p class=MsoNormal><b><i><span style='font-size:10.0pt'>borland_ibase</span></i></b></p>
  1731. </td>
  1732. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1733. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1734. </td>
  1735. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1736. <p class=MsoNormal><span style='font-size:10.0pt'>Borland version of
  1737. Interbase 6.5 or later. Very sad that the forks differ.</span></p>
  1738. </td>
  1739. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1740. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1741. </td>
  1742. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1743. <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
  1744. </td>
  1745. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1746. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1747. </td>
  1748. </tr>
  1749. <tr style='mso-yfti-irow:12'>
  1750. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1751. <p class=MsoNormal><b><span style='font-size:10.0pt'>informix</span></b></p>
  1752. </td>
  1753. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1754. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1755. </td>
  1756. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1757. <p class=MsoNormal><span style='font-size:10.0pt'>Generic informix driver.
  1758. Use this if you are using Informix 7.3 or later.</span></p>
  1759. </td>
  1760. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1761. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1762. </td>
  1763. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1764. <p class=MsoNormal><span style='font-size:10.0pt'>Informix client</span></p>
  1765. </td>
  1766. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1767. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1768. </td>
  1769. </tr>
  1770. <tr style='mso-yfti-irow:13'>
  1771. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1772. <p class=MsoNormal><b><span style='font-size:10.0pt'>informix72</span></b></p>
  1773. </td>
  1774. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1775. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1776. </td>
  1777. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1778. <p class=MsoNormal><span style='font-size:10.0pt'>Informix databases before
  1779. Informix 7.3 that do no support SELECT FIRST.</span></p>
  1780. </td>
  1781. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1782. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1783. </td>
  1784. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1785. <p class=MsoNormal><span style='font-size:10.0pt'>Informix client</span></p>
  1786. </td>
  1787. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1788. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1789. </td>
  1790. </tr>
  1791. <tr style='mso-yfti-irow:14'>
  1792. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1793. <p class=MsoNormal><b><span style='font-size:10.0pt'>ldap</span></b></p>
  1794. </td>
  1795. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1796. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1797. </td>
  1798. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1799. <p class=MsoNormal><span style='font-size:10.0pt'>LDAP driver. See this
  1800. example for usage information.</span></p>
  1801. </td>
  1802. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1803. <p class=MsoNormal>&nbsp;</p>
  1804. </td>
  1805. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1806. <p class=MsoNormal><span style='font-size:10.0pt'>LDAP extension</span></p>
  1807. </td>
  1808. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1809. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  1810. </td>
  1811. </tr>
  1812. <tr style='mso-yfti-irow:15;height:54.75pt'>
  1813. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1814. <p class=MsoNormal><b><span style='font-size:10.0pt'>mssql</span></b></p>
  1815. </td>
  1816. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1817. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1818. </td>
  1819. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1820. <p><span style='font-size:10.0pt'>Microsoft SQL Server 7 and later. Works
  1821. with Microsoft SQL Server 2000 also. Note that date formating is problematic
  1822. with this driver. For example, the PHP mssql extension does not return the
  1823. seconds for datetime!</span></p>
  1824. </td>
  1825. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1826. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1827. </td>
  1828. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1829. <p class=MsoNormal><span style='font-size:10.0pt'>Mssql client</span></p>
  1830. </td>
  1831. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1832. <p><span style='font-size:10.0pt'>Unix and Windows. <br>
  1833. <a href="http://phpbuilder.com/columns/alberto20000919.php3">Unix install
  1834. howto</a> and <a
  1835. href="http://www.linuxjournal.com/article/6636">another
  1836. one</a>. </span></p>
  1837. </td>
  1838. </tr>
  1839. <tr style='mso-yfti-irow:16;height:54.75pt'>
  1840. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1841. <p class=MsoNormal><b><span style='font-size:10.0pt'>mssqlpo</span></b></p>
  1842. </td>
  1843. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1844. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1845. </td>
  1846. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1847. <p><span style='font-size:10.0pt'>Portable mssql driver. Identical to above mssql
  1848. driver, except that '||', the concatenation operator, is converted to '+'.
  1849. Useful for porting scripts from most other sql variants that use ||.</span></p>
  1850. </td>
  1851. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1852. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1853. </td>
  1854. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1855. <p class=MsoNormal><span style='font-size:10.0pt'>Mssql client</span></p>
  1856. </td>
  1857. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1858. <p><span style='font-size:10.0pt'>Unix and Windows. <a
  1859. href="http://phpbuilder.com/columns/alberto20000919.php3"><br>
  1860. Unix install howto</a>.</span></p>
  1861. </td>
  1862. </tr>
  1863. <tr style='mso-yfti-irow:17;height:54.75pt'>
  1864. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1865. <p class=MsoNormal><b><span style='font-size:10.0pt'>mssqlnative</span></b></p>
  1866. </td>
  1867. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1868. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1869. </td>
  1870. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1871. <p><span style='font-size:10.0pt'>Native mssql driver from M'soft. Use with PHP 5.3 or later. </span></p>
  1872. </td>
  1873. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1874. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  1875. </td>
  1876. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1877. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  1878. </td>
  1879. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
  1880. <p><span style='font-size:10.0pt'>Windows. Tq Garrett Serack of M'soft.</span></p>
  1881. </td>
  1882. </tr>
  1883. <tr style='mso-yfti-irow:18'>
  1884. <td style='padding:.75pt .75pt .75pt .75pt'>
  1885. <p class=MsoNormal><o:p>&nbsp;</o:p></p>
  1886. </td>
  1887. <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
  1888. <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p>&nbsp;</o:p></span></p>
  1889. </td>
  1890. <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
  1891. <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p>&nbsp;</o:p></span></p>
  1892. </td>
  1893. <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
  1894. <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p>&nbsp;</o:p></span></p>
  1895. </td>
  1896. <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
  1897. <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p>&nbsp;</o:p></span></p>
  1898. </td>
  1899. <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
  1900. <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p>&nbsp;</o:p></span></p>
  1901. </td>
  1902. </tr>
  1903. <tr style='mso-yfti-irow:19'>
  1904. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1905. <p class=MsoNormal><b><span style='font-size:10.0pt'>mysql</span></b></p>
  1906. </td>
  1907. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1908. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1909. </td>
  1910. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1911. <p class=MsoNormal><span style='font-size:10.0pt'>MySQL without transaction
  1912. support. You can also set $db-&gt;clientFlags before connecting.</span></p>
  1913. </td>
  1914. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1915. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  1916. </td>
  1917. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1918. <p class=MsoNormal><span style='font-size:10.0pt'>MySQL client</span></p>
  1919. </td>
  1920. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1921. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1922. </td>
  1923. </tr>
  1924. <tr style='mso-yfti-irow:20'>
  1925. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1926. <p class=MsoNormal><b><span style='font-size:10.0pt'>mysqlt</span></b><span
  1927. style='font-size:10.0pt'> or <b>maxsql</b></span></p>
  1928. </td>
  1929. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1930. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1931. </td>
  1932. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1933. <p><span style='font-size:10.0pt'>MySQL with transaction support. We
  1934. recommend using || as the concat operator for best portability. This can be
  1935. done by running MySQL using: <br>
  1936. <i>mysqld --ansi</i> or <i>mysqld --sql-mode=PIPES_AS_CONCAT</i></span></p>
  1937. </td>
  1938. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1939. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1940. </td>
  1941. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1942. <p class=MsoNormal><span style='font-size:10.0pt'>MySQL client</span></p>
  1943. </td>
  1944. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1945. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1946. </td>
  1947. </tr>
  1948. <tr style='mso-yfti-irow:21'>
  1949. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1950. <p class=MsoNormal><b><span style='font-size:10.0pt'>oci8</span></b></p>
  1951. </td>
  1952. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1953. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  1954. </td>
  1955. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1956. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle 8/9. Has more
  1957. functionality than <i>oracle</i> driver (eg. Affected_Rows). You might have
  1958. to putenv('ORACLE_HOME=...') before Connect/PConnect. </span></p>
  1959. <p><span style='font-size:10.0pt'>There are 2 ways of connecting - with
  1960. server IP and service name: <br>
  1961. <i>PConnect('serverip:1521','scott','tiger','service'</i>)<br>
  1962. or using an entry in TNSNAMES.ORA or ONAMES or HOSTNAMES: <br>
  1963. <i>PConnect(false, 'scott', 'tiger', $oraname)</i>. </span></p>
  1964. <p><span style='font-size:10.0pt'>Since 2.31, we support Oracle REF cursor
  1965. variables directly (see <a href="#executecursor">ExecuteCursor</a>).</span> </p>
  1966. </td>
  1967. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1968. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1969. </td>
  1970. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1971. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
  1972. </td>
  1973. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1974. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1975. </td>
  1976. </tr>
  1977. <tr style='mso-yfti-irow:22'>
  1978. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1979. <p class=MsoNormal><b><span style='font-size:10.0pt'>oci805</span></b></p>
  1980. </td>
  1981. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1982. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  1983. </td>
  1984. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1985. <p class=MsoNormal><span style='font-size:10.0pt'>Supports reduced Oracle
  1986. functionality for Oracle 8.0.5. SelectLimit is not as efficient as in the
  1987. oci8 or oci8po drivers.</span></p>
  1988. </td>
  1989. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1990. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  1991. </td>
  1992. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1993. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
  1994. </td>
  1995. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  1996. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  1997. </td>
  1998. </tr>
  1999. <tr style='mso-yfti-irow:23'>
  2000. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2001. <p class=MsoNormal><b><span style='font-size:10.0pt'>oci8po</span></b></p>
  2002. </td>
  2003. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2004. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2005. </td>
  2006. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2007. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle 8/9 portable driver.
  2008. This is nearly identical with the oci8 driver except (a) bind variables in
  2009. Prepare() use the ? convention, instead of :bindvar, (b) field names use the
  2010. more common PHP convention of lowercase names. </span></p>
  2011. <p><span style='font-size:10.0pt'>Use this driver if porting from other
  2012. databases is important. Otherwise the oci8 driver offers better performance. </span></p>
  2013. </td>
  2014. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2015. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2016. </td>
  2017. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2018. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
  2019. </td>
  2020. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2021. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  2022. </td>
  2023. </tr>
  2024. <tr style='mso-yfti-irow:24'>
  2025. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2026. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc</span></b></p>
  2027. </td>
  2028. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2029. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2030. </td>
  2031. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2032. <p class=MsoNormal><span style='font-size:10.0pt'>Generic ODBC, not tuned for
  2033. specific databases. To connect, use <br>
  2034. PConnect('DSN','user','pwd'). This is the base class for all odbc derived
  2035. drivers.</span></p>
  2036. </td>
  2037. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2038. <p class=MsoNormal><span style='font-size:10.0pt'>? depends on database</span></p>
  2039. </td>
  2040. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2041. <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
  2042. </td>
  2043. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2044. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. <a
  2045. href="http://phpbuilder.com/columns/alberto20000919.php3?page=4">Unix hints.</a></span></p>
  2046. </td>
  2047. </tr>
  2048. <tr style='mso-yfti-irow:25'>
  2049. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2050. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_mssql</span></b></p>
  2051. </td>
  2052. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2053. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2054. </td>
  2055. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2056. <p class=MsoNormal><span style='font-size:10.0pt'>Uses ODBC to connect to
  2057. MSSQL</span></p>
  2058. </td>
  2059. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2060. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2061. </td>
  2062. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2063. <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
  2064. </td>
  2065. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2066. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2067. </td>
  2068. </tr>
  2069. <tr style='mso-yfti-irow:26'>
  2070. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2071. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_oracle</span></b></p>
  2072. </td>
  2073. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2074. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2075. </td>
  2076. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2077. <p class=MsoNormal><span style='font-size:10.0pt'>Uses ODBC to connect to
  2078. Oracle</span></p>
  2079. </td>
  2080. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2081. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2082. </td>
  2083. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2084. <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
  2085. </td>
  2086. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2087. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2088. </td>
  2089. </tr>
  2090. <tr style='mso-yfti-irow:27'>
  2091. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2092. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbtp</span></b></p>
  2093. </td>
  2094. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2095. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2096. </td>
  2097. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2098. <p class=MsoNormal><span style='font-size:10.0pt'>Generic odbtp driver. <a
  2099. href="http://odbtp.sourceforge.net/">Odbtp</a> is a software for accessing
  2100. Windows ODBC data sources from other operating systems.</span></p>
  2101. </td>
  2102. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2103. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2104. </td>
  2105. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2106. <p class=MsoNormal><span style='font-size:10.0pt'>odbtp</span></p>
  2107. </td>
  2108. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2109. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  2110. </td>
  2111. </tr>
  2112. <tr style='mso-yfti-irow:28'>
  2113. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2114. <p class=MsoNormal><b><span style='font-size:10.0pt'>odbtp_unicode</span></b></p>
  2115. </td>
  2116. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2117. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2118. </td>
  2119. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2120. <p class=MsoNormal><span style='font-size:10.0pt'>Odtbp with unicode support</span></p>
  2121. </td>
  2122. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2123. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2124. </td>
  2125. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2126. <p class=MsoNormal><span style='font-size:10.0pt'>odbtp</span></p>
  2127. </td>
  2128. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2129. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  2130. </td>
  2131. </tr>
  2132. <tr style='mso-yfti-irow:29;height:25.5pt'>
  2133. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2134. <p class=MsoNormal><b><span style='font-size:10.0pt'>oracle</span></b></p>
  2135. </td>
  2136. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2137. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2138. </td>
  2139. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2140. <p class=MsoNormal><span style='font-size:10.0pt'>Implements old Oracle 7
  2141. client API. Use oci8 driver if possible for better performance.</span></p>
  2142. </td>
  2143. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2144. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2145. </td>
  2146. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2147. <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
  2148. </td>
  2149. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2150. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
  2151. </td>
  2152. </tr>
  2153. <tr style='mso-yfti-irow:30;height:25.5pt'>
  2154. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2155. <p class=MsoNormal><b><span style='font-size:10.0pt'>netezza</span></b></p>
  2156. </td>
  2157. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2158. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2159. </td>
  2160. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2161. <p class=MsoNormal><span style='font-size:10.0pt'>Netezza driver. Netezza is
  2162. based on postgres code-base.</span></p>
  2163. </td>
  2164. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2165. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2166. </td>
  2167. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2168. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  2169. </td>
  2170. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
  2171. <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
  2172. </td>
  2173. </tr>
  2174. <tr style='mso-yfti-irow:31'>
  2175. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2176. <p class=MsoNormal><b><span style='font-size:10.0pt'>pdo</span></b></p>
  2177. </td>
  2178. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2179. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2180. </td>
  2181. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2182. <p class=MsoNormal><span style='font-size:10.0pt'>Generic PDO driver for
  2183. PHP5. </span></p>
  2184. </td>
  2185. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2186. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2187. </td>
  2188. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2189. <p class=MsoNormal><span style='font-size:10.0pt'>PDO extension and database
  2190. specific drivers</span></p>
  2191. </td>
  2192. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2193. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2194. </td>
  2195. </tr>
  2196. <tr style='mso-yfti-irow:32'>
  2197. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2198. <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres</span></b></p>
  2199. </td>
  2200. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2201. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2202. </td>
  2203. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2204. <p class=MsoNormal><span style='font-size:10.0pt'>Generic PostgreSQL driver.
  2205. Currently identical to postgres7 driver.</span></p>
  2206. </td>
  2207. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2208. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2209. </td>
  2210. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2211. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
  2212. </td>
  2213. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2214. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2215. </td>
  2216. </tr>
  2217. <tr style='mso-yfti-irow:33'>
  2218. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2219. <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres64</span></b></p>
  2220. </td>
  2221. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2222. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2223. </td>
  2224. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2225. <p class=MsoNormal><span style='font-size:10.0pt'>For PostgreSQL 6.4 and
  2226. earlier which does not support LIMIT internally.</span></p>
  2227. </td>
  2228. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2229. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2230. </td>
  2231. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2232. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
  2233. </td>
  2234. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2235. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2236. </td>
  2237. </tr>
  2238. <tr style='mso-yfti-irow:34'>
  2239. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2240. <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres7</span></b></p>
  2241. </td>
  2242. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2243. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2244. </td>
  2245. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2246. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
  2247. LIMIT and other version 7 functionality.</span></p>
  2248. </td>
  2249. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2250. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2251. </td>
  2252. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2253. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
  2254. </td>
  2255. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2256. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2257. </td>
  2258. </tr>
  2259. <tr style='mso-yfti-irow:35'>
  2260. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2261. <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres8</span></b></p>
  2262. </td>
  2263. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2264. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2265. </td>
  2266. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2267. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
  2268. version 8 functionality.</span></p>
  2269. </td>
  2270. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2271. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2272. </td>
  2273. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2274. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
  2275. </td>
  2276. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2277. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2278. </td>
  2279. </tr>
  2280. <tr style='mso-yfti-irow:35'>
  2281. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2282. <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres9</span></b></p>
  2283. </td>
  2284. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2285. <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
  2286. </td>
  2287. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2288. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
  2289. version 9 functionality.</span></p>
  2290. </td>
  2291. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2292. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2293. </td>
  2294. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2295. <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
  2296. </td>
  2297. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2298. <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
  2299. </td>
  2300. </tr>
  2301. <tr style='mso-yfti-irow:36'>
  2302. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2303. <p class=MsoNormal><b><span style='font-size:10.0pt'>sapdb</span></b></p>
  2304. </td>
  2305. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2306. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2307. </td>
  2308. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2309. <p class=MsoNormal><span style='font-size:10.0pt'>SAP DB. Should work
  2310. reliably as based on ODBC driver.</span></p>
  2311. </td>
  2312. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2313. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2314. </td>
  2315. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2316. <p class=MsoNormal><span style='font-size:10.0pt'>SAP ODBC client</span></p>
  2317. </td>
  2318. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2319. <p><span style='font-size:10.0pt'>?</span></p>
  2320. </td>
  2321. </tr>
  2322. <tr style='mso-yfti-irow:37'>
  2323. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2324. <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlanywhere</span></b></p>
  2325. </td>
  2326. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2327. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2328. </td>
  2329. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2330. <p class=MsoNormal><span style='font-size:10.0pt'>Sybase SQL Anywhere. Should
  2331. work reliably as based on ODBC driver.</span></p>
  2332. </td>
  2333. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2334. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2335. </td>
  2336. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2337. <p class=MsoNormal><span style='font-size:10.0pt'>SQL Anywhere ODBC client</span></p>
  2338. </td>
  2339. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2340. <p><span style='font-size:10.0pt'>?</span></p>
  2341. </td>
  2342. </tr>
  2343. <tr style='mso-yfti-irow:38;height:40.5pt'>
  2344. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2345. <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlite</span></b></p>
  2346. </td>
  2347. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2348. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  2349. </td>
  2350. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2351. <p class=MsoNormal><span style='font-size:10.0pt'>SQLite.</span></p>
  2352. </td>
  2353. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2354. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2355. </td>
  2356. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2357. <p class=MsoNormal><span style='font-size:10.0pt'>-</span></p>
  2358. </td>
  2359. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2360. <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
  2361. </td>
  2362. </tr>
  2363. <tr style='mso-yfti-irow:39;height:40.5pt'>
  2364. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2365. <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlitepo</span></b></p>
  2366. </td>
  2367. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2368. <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
  2369. </td>
  2370. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2371. <p class=MsoNormal><span style='font-size:10.0pt'>Portable SQLite driver. This
  2372. is because assoc mode does not work like other drivers in sqlite. Namely,
  2373. when selecting (joining) multiple tables, the table names are included in the
  2374. assoc keys in the &quot;sqlite&quot; driver.</span></p>
  2375. <p><span style='font-size:10.0pt'>In &quot;sqlitepo&quot; driver, the table
  2376. names are stripped from the returned column names. When this results in a
  2377. conflict, the first field get preference. </span></p>
  2378. </td>
  2379. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2380. <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
  2381. </td>
  2382. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2383. <p class=MsoNormal><span style='font-size:10.0pt'>-</span></p>
  2384. </td>
  2385. <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
  2386. <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
  2387. </td>
  2388. </tr>
  2389. <tr style='mso-yfti-irow:40'>
  2390. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2391. <p class=MsoNormal><b><span style='font-size:10.0pt'>sybase</span></b></p>
  2392. </td>
  2393. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2394. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2395. </td>
  2396. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2397. <p class=MsoNormal><span style='font-size:10.0pt'>Sybase. </span></p>
  2398. </td>
  2399. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2400. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2401. </td>
  2402. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2403. <p class=MsoNormal><span style='font-size:10.0pt'>Sybase client</span></p>
  2404. </td>
  2405. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2406. <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
  2407. </td>
  2408. </tr>
  2409. <tr style='mso-yfti-irow:41;mso-yfti-lastrow:yes'>
  2410. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2411. <p class=MsoNormal><b><span style='font-size:10.0pt'>sybase_ase</span></b></p>
  2412. </td>
  2413. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2414. <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
  2415. </td>
  2416. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2417. <p class=MsoNormal><span style='font-size:10.0pt'>Sybase ASE. </span></p>
  2418. </td>
  2419. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2420. <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
  2421. </td>
  2422. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2423. <p class=MsoNormal><span style='font-size:10.0pt'>Sybase client</span></p>
  2424. </td>
  2425. <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  2426. <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
  2427. </td>
  2428. </tr>
  2429. </table>
  2430. <p>The &quot;Tested&quot; column indicates how extensively the code has been
  2431. tested and used. <br>
  2432. A = well tested and used by many people<br>
  2433. B = tested and usable, but some features might not be implemented<br>
  2434. C = user contributed or experimental driver. Might not fully support all of the
  2435. latest features of ADOdb. </p>
  2436. <p>The column &quot;RecordCount() usable&quot; indicates whether RecordCount()
  2437. return the number of rows, or returns -1 when a SELECT statement is executed.
  2438. If this column displays Y/N then the RecordCount() is emulated when the global
  2439. variable $ADODB_COUNTRECS=true (this is the default). Note that for large
  2440. recordsets, it might be better to disable RecordCount() emulation because
  2441. substantial amounts of memory are required to cache the recordset for counting.
  2442. Also there is a speed penalty of 40-50% if emulation is required. This is
  2443. emulated in most databases except for PostgreSQL and MySQL. This variable is
  2444. checked every time a query is executed, so you can selectively choose which
  2445. recordsets to count.</p>
  2446. <div class=MsoNormal align=center style='text-align:center'>
  2447. <hr size=2 width="100%" align=center>
  2448. </div>
  2449. <h1>Tutorials<a name=quickstart></a></h1>
  2450. <h3>Example 1: Select Statement<a name=ex1></a></h3>
  2451. <p>Task: Connect to the Access Northwind DSN, display the first 2 columns of
  2452. each row.</p>
  2453. <p>In this example, we create a ADOConnection object, which represents the
  2454. connection to the database. The connection is initiated with <a href="#pconnect"><span
  2455. style='font-family:"Courier New"'>PConnect</span></a>, which is a persistent
  2456. connection. Whenever we want to query the database, we call the <span
  2457. style='font-family:"Courier New"'>ADOConnection.<a href="#execute">Execute</a>()</span>
  2458. function. This returns an ADORecordSet object which is actually a cursor that
  2459. holds the current row in the array <span style='font-family:"Courier New"'>fields[]</span>.
  2460. We use <span style='font-family:"Courier New"'><a href="#movenext">MoveNext</a>()</span>
  2461. to move from row to row.</p>
  2462. <p>NB: A useful function that is not used in this example is <span
  2463. style='font-family:"Courier New"'><a href="#selectlimit">SelectLimit</a></span>,
  2464. which allows us to limit the number of rows shown. </p>
  2465. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2466. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?<br>
  2467. <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># load code common to ADOdb<br>
  2468. $<span style='color:#660000'>conn</span> = &amp;ADONewConnection('access');<span
  2469. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># create a connection<br>
  2470. $<span style='color:#660000'>conn</span>-&gt;PConnect('northwind');<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># connect to MS-Access, northwind DSN<br>
  2471. $<span style='color:#660000'>recordSet</span> = &amp;$<span style='color:#660000'>conn</span>-&gt;Execute('select * from products');<br>
  2472. if (!$<span style='color:#660000'>recordSet</span>) <br>
  2473. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print $<span style='color:#660000'>conn</span>-&gt;ErrorMsg();<br>
  2474. else<br>
  2475. <b>while</b> (!$<span style='color:#660000'>recordSet</span>-&gt;EOF) {<br>
  2476. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>print</b> $<span
  2477. style='color:#660000'>recordSet</span>-&gt;fields[0].' '.$<span
  2478. style='color:#660000'>recordSet</span>-&gt;fields[1].'&lt;BR&gt;';<br>
  2479. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$<span style='color:#660000'>recordSet</span>-&gt;MoveNext();<br>
  2480. }</pre><pre><o:p>&nbsp;</o:p></pre><pre>$<span style='color:#660000'>recordSet</span>-&gt;Close(); # optional<br>
  2481. $<span style='color:#660000'>conn</span>-&gt;Close(); # optional<br
  2482. style='mso-special-character:line-break'>
  2483. <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
  2484. <![endif]></pre><pre>?&gt;</pre></div>
  2485. <p>The $<span style='font-family:"Courier New"'>recordSet</span> returned
  2486. stores the current row in the <span style='font-family:"Courier New"'>$recordSet-&gt;fields</span>
  2487. array, indexed by column number (starting from zero). We use the <span
  2488. style='font-family:"Courier New"'><a href="#movenext">MoveNext</a>()</span>
  2489. function to move to the next row. The <span style='font-family:"Courier New"'>EOF</span>
  2490. property is set to true when end-of-file is reached. If an error occurs in
  2491. Execute(), we return false instead of a recordset.</p>
  2492. <p>The <code><span style='font-size:10.0pt'>$recordSet-&gt;fields[]</span></code>
  2493. array is generated by the PHP database extension. Some database extensions only
  2494. index by number and do not index the array by field name. To force indexing by
  2495. name - that is associative arrays - use the SetFetchMode function. Each
  2496. recordset saves and uses whatever fetch mode was set when the recordset was
  2497. created in Execute() or SelectLimit(). </p>
  2498. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2499. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  2500. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;SetFetchMode(ADODB_FETCH_NUM);<br>
  2501. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs1 = $db-&gt;Execute('select * from table');<br>
  2502. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;SetFetchMode(ADODB_FETCH_ASSOC);<br>
  2503. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs2 = $db-&gt;Execute('select * from table');<br>
  2504. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs1-&gt;fields); # shows <i>array([0]=&gt;'v0',[1] =&gt;'v1')</i></pre><pre><span
  2505. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs2-&gt;fields); # shows <i>array(['col1']=&gt;'v0',['col2'] =&gt;'v1')</i></pre></div>
  2506. <p>To get the number of rows in the select statement, you can use <span
  2507. style='font-family:"Courier New"'>$recordSet-&gt;<a href="#recordcount">RecordCount</a>()</span>.
  2508. Note that it can return -1 if the number of rows returned cannot be determined.</p>
  2509. <h3>Example 2: Advanced Select with Field Objects<a name=ex2></a></h3>
  2510. <p>Select a table, display the first two columns. If the second column is a
  2511. date or timestamp, reformat the date to <st1:country-region w:st="on"><st1:place
  2512. w:st="on">US</st1:place></st1:country-region> format.</p>
  2513. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2514. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?<br>
  2515. <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># load code common to ADOdb<br>
  2516. $<span style='color:#660000'>conn</span> = &amp;ADONewConnection('access');<span
  2517. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># create a connection<br>
  2518. $<span style='color:#660000'>conn</span>-&gt;PConnect('northwind');<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># connect to MS-Access, northwind dsn<br>
  2519. $<span style='color:#660000'>recordSet</span> = &amp;$<span style='color:#660000'>conn</span>-&gt;Execute('select CustomerID,OrderDate from Orders');<br>
  2520. if (!$<span style='color:#660000'>recordSet</span>) <br>
  2521. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print $<span style='color:#660000'>conn</span>-&gt;ErrorMsg();<br>
  2522. else<br>
  2523. <b>while</b> (!$<span style='color:#660000'>recordSet</span>-&gt;EOF) {<br>
  2524. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$<span style='color:#660000'>fld</span> = <b><span
  2525. style='color:#336600'>$</span></b><span style='color:#660000'>recordSet</span><b><span
  2526. style='color:#336600'>-&gt;FetchField</span></b><span style='color:#006600'>(</span>1<span
  2527. style='color:#006600'>);</span></pre><pre><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$<span
  2528. style='color:#660000'>type</span> = <b><span style='color:#336600'>$</span></b><span
  2529. style='color:#660000'>recordSet</span><b><span style='color:#336600'>-&gt;MetaType</span></b>($fld-&gt;type);<br>
  2530. <br>
  2531. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>if</b> ( $<span
  2532. style='color:#660000'>type</span> == 'D' || $<span style='color:#660000'>type</span> == 'T') <br>
  2533. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>print</b> $<span
  2534. style='color:#660000'>recordSet</span>-&gt;fields[0].' '.<br>
  2535. <span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span
  2536. style='color:#336600'>$</span></b><span style='color:#660000'>recordSet</span><b><span
  2537. style='color:#336600'>-&gt;UserDate</span></b>($<span style='color:#660000'>recordSet</span>-&gt;fields[1],'<b>m/d/Y</b>').'&lt;BR&gt;';<br>
  2538. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>else </b></pre><pre><span
  2539. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>print</b> $<span
  2540. style='color:#660000'>recordSet</span>-&gt;fields[0].' '.$<span
  2541. style='color:#660000'>recordSet</span>-&gt;fields[1].'&lt;BR&gt;';<br>
  2542. <br>
  2543. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$<span style='color:#660000'>recordSet</span>-&gt;MoveNext();<br>
  2544. }</pre><pre>$<span style='color:#660000'>recordSet</span>-&gt;Close(); # optional<br>
  2545. $<span style='color:#660000'>conn</span>-&gt;Close(); # optional<br
  2546. style='mso-special-character:line-break'>
  2547. <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
  2548. <![endif]></pre><pre>?&gt;</pre></div>
  2549. <p>In this example, we check the field type of the second column using <span
  2550. style='font-family:"Courier New"'><a href="#fetchfield">FetchField</a>().</span>
  2551. This returns an object with at least 3 fields.</p>
  2552. <ul type=disc>
  2553. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2554. mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>name</b>: name of column</li>
  2555. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2556. mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>type</b>: native field
  2557. type of column</li>
  2558. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2559. mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>max_length</b>: maximum
  2560. length of field. Some databases such as MySQL do not return the maximum
  2561. length of the field correctly. In these cases max_length will be set to
  2562. -1.</li>
  2563. </ul>
  2564. <p>We then use <span style='font-family:"Courier New"'><a href="#metatype">MetaType</a>()</span>
  2565. to translate the native type to a <i>generic</i> type. Currently the following <i>generic</i>
  2566. types are defined:</p>
  2567. <ul type=disc>
  2568. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2569. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>C</b>: character fields
  2570. that should be shown in a &lt;input type=&quot;text&quot;&gt; tag.</li>
  2571. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2572. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>X</b>: TeXt, large text
  2573. fields that should be shown in a &lt;textarea&gt;</li>
  2574. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2575. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>B</b>: Blobs, or Binary
  2576. Large Objects. Typically images. </li>
  2577. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2578. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>D</b>: Date field</li>
  2579. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2580. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>T</b>: Timestamp field</li>
  2581. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2582. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>L</b>: Logical field
  2583. (boolean or bit-field)</li>
  2584. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2585. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>I</b>:&nbsp; Integer
  2586. field</li>
  2587. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2588. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>N</b>: Numeric field.
  2589. Includes autoincrement, numeric, floating point, real and integer. </li>
  2590. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  2591. mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>R</b>: Serial field.
  2592. Includes serial, autoincrement integers. This works for selected
  2593. databases. </li>
  2594. </ul>
  2595. <p>If the metatype is of type date or timestamp, then we print it using the
  2596. user defined date format with <span style='font-family:"Courier New"'><a
  2597. href="#userdate">UserDate</a>(),</span> which converts the PHP SQL date string
  2598. format to a user defined one. Another use for <span style='font-family:"Courier New"'><a
  2599. href="#metatype">MetaType</a>()</span> is data validation before doing an SQL
  2600. insert or update.</p>
  2601. <h3>Example 3: Inserting<a name=ex3></a></h3>
  2602. <p>Insert a row to the Orders table containing dates and strings that need to
  2603. be quoted before they can be accepted by the database, eg: the single-quote in
  2604. the word <i>John's</i>.</p>
  2605. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2606. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2607. style='background:#EEEEEE'>&lt;?<br>
  2608. <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># load code common to ADOdb<br>
  2609. $<span style='color:#660000'>conn</span> = &amp;ADONewConnection('access');<span
  2610. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># create a connection<br>
  2611. <br>
  2612. $<span style='color:#660000'>conn</span>-&gt;PConnect('northwind');<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># connect to MS-Access, northwind dsn<br>
  2613. $<span style='color:#660000'>shipto</span> = <b><span style='color:#006600'>$conn-&gt;qstr</span></b>(&quot;<i>John's Old Shoppe</i>&quot;);<br>
  2614. <br>
  2615. $<span style='color:#660000'>sql</span> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;<br>
  2616. $<span style='color:#660000'>sql</span> .= &quot;values ('ANATR',2,&quot;.<b><span
  2617. style='color:#006600'>$conn-&gt;DBDate(</span>time()</b><b><span
  2618. style='color:#006600'>)</span></b><span style='color:#006600'>.</span>&quot;,$<span
  2619. style='color:#660000'>shipto</span>)&quot;;<br>
  2620. <br>
  2621. <b>if</b> ($<span style='color:#660000'>conn</span>-&gt;Execute($<span
  2622. style='color:#660000'>sql</span>) <b><span style='color:#336600'>=== false</span></b>) {<br>
  2623. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>print</b> 'error inserting: '.<b><span
  2624. style='color:#336600'>$conn-&gt;ErrorMsg()</span></b>.'&lt;BR&gt;';<br>
  2625. }<br>
  2626. ?&gt;</pre></div>
  2627. <p>In this example, we see the advanced date and quote handling facilities of
  2628. ADOdb. The unix timestamp (which is a long integer) is appropriately formated
  2629. for Access with <span style='font-family:"Courier New"'><a href="#dbdate">DBDate</a>()</span>,
  2630. and the right escape character is used for quoting the <i>John's Old Shoppe</i>,
  2631. which is<b> </b><i>John'<b>'</b>s Old Shoppe</i> and not PHP's default <i>John<b>'</b>s
  2632. Old Shoppe</i> with <span style='font-family:"Courier New"'><a href="#qstr">qstr</a>()</span>.
  2633. </p>
  2634. <p>Observe the error-handling of the Execute statement. False is returned by<span
  2635. style='font-family:"Courier New"'> <a href="#execute">Execute</a>() </span>if
  2636. an error occured. The error message for the last error that occurred is
  2637. displayed in <span style='font-family:"Courier New"'><a href="#errormsg">ErrorMsg</a>()</span>.
  2638. Note: <i>php_track_errors</i> might have to be enabled for error messages to be
  2639. saved.</p>
  2640. <h3>Example 4: Debugging<a name=ex4></a></h3>
  2641. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2642. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?<br>
  2643. <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># load code common to ADOdb<br>
  2644. $<span style='color:#663300'>conn</span> = &amp;ADONewConnection('access');<span
  2645. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># create a connection<br>
  2646. $<span style='color:#663300'>conn</span>-&gt;PConnect('northwind');<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># connect to MS-Access, northwind dsn<br>
  2647. $<span style='color:#663300'>shipto</span> = <b>$conn-&gt;qstr</b>(&quot;John's Old Shoppe&quot;);<br>
  2648. $<span style='color:#663300'>sql</span> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;<br>
  2649. $<span style='color:#663300'>sql</span> .= &quot;values ('ANATR',2,&quot;.$<span
  2650. style='color:#663300'>conn</span>-&gt;FormatDate(time()).&quot;,$shipto)&quot;;<br>
  2651. <b><span style='color:#336600'>$</span></b><b><span style='color:#663300'>conn</span></b><b><span
  2652. style='color:#336600'>-&gt;debug = true;</span></b></pre><pre><b>if</b> ($<span
  2653. style='color:#663300'>conn</span>-&gt;Execute($sql) <b>=== false</b>) <b>print</b> 'error inserting';</pre><pre>?&gt;</pre></div>
  2654. <p>In the above example, we have turned on debugging by setting <b>debug = true</b>.
  2655. This will display the SQL statement before execution, and also show any error
  2656. messages. There is no need to call <span style='font-family:"Courier New"'><a
  2657. href="#errormsg">ErrorMsg</a>()</span> in this case. For displaying the
  2658. recordset, see the <span style='font-family:"Courier New"'><a href="#exrs2html">rs2html</a>()
  2659. </span>example.</p>
  2660. <p>Also see the section on <a href="#errorhandling">Custom Error Handlers</a>.</p>
  2661. <h3>Example 5: MySQL and Menus<a name=ex5></a></h3>
  2662. <p>Connect to MySQL database <i>agora</i>, and generate a &lt;select&gt; menu
  2663. from an SQL statement where the &lt;option&gt; captions are in the 1st column,
  2664. and the value to send back to the server is in the 2nd column.</p>
  2665. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2666. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2667. style='background:#EEEEEE'>&lt;?<br>
  2668. <b>include</b>('adodb.inc.php'); # load code common to ADOdb<br>
  2669. $<span style='color:#663300'>conn</span> = &amp;ADONewConnection('mysql');<span style='mso-spacerun:yes'>&nbsp; </span># create a connection<br>
  2670. $<span style='color:#663300'>conn</span>-&gt;PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
  2671. $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers';<br>
  2672. $<span style='color:#663300'>rs</span> = $<span style='color:#663300'>conn</span>-&gt;Execute($sql);<br>
  2673. <b>print</b> <b><span style='color:#336600'>$</span></b><b><span
  2674. style='color:#663300'>rs</span></b><b><span style='color:#336600'>-&gt;GetMenu('GetCust','Mary Rosli');<br>
  2675. ?&gt;</span></b></pre></div>
  2676. <p>Here we define a menu named GetCust, with the menu option 'Mary Rosli'
  2677. selected. See <a href="#getmenu"><span style='font-family:"Courier New"'>GetMenu</span></a><span
  2678. style='font-family:"Courier New"'>()</span>. We also have functions that return
  2679. the recordset as an array: <span style='font-family:"Courier New"'><a
  2680. href="#getarray">GetArray</a>()</span>, and as an associative array with the
  2681. key being the first column: <a href="#getassoc1">GetAssoc</a>().</p>
  2682. <h3>Example 6: Connecting to 2 Databases At Once<a name=ex6></a></h3>
  2683. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2684. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2685. style='background:#EEEEEE'>&lt;?<br>
  2686. <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span> # load code common to ADOdb<br>
  2687. $<span style='color:#663300'>conn1</span> = &amp;ADONewConnection('mysql');<span style='mso-spacerun:yes'>&nbsp; </span># create a mysql connection<br>
  2688. $<span style='color:#663300'>conn2</span> = &amp;ADONewConnection('oracle');<span style='mso-spacerun:yes'>&nbsp; </span># create a oracle connection<br>
  2689. <br>
  2690. $conn1-&gt;PConnect($server, $userid, $password, $database);<br>
  2691. $conn2-&gt;PConnect(false, $ora_userid, $ora_pwd, $oraname);<br>
  2692. <br>
  2693. $conn1-&gt;Execute('insert ...');<br>
  2694. $conn2-&gt;Execute('update ...');<br>
  2695. ?&gt;</pre></div>
  2696. <h3>Example 7: Generating Update and Insert SQL<a name=ex7></a></h3>
  2697. <p>Since ADOdb 4.56, we support <a
  2698. href="reference.functions.getupdatesql.html#autoexecute">AutoExecute()</a>,
  2699. which simplifies things by providing an advanced wrapper for GetInsertSQL() and
  2700. GetUpdateSQL(). For example, an INSERT can be carried out with: </p>
  2701. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2702. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>$record[&quot;firstname&quot;] = &quot;Bob&quot;; </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>$record[&quot;lastname&quot;] = &quot;Smith&quot;; </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>$record[&quot;created&quot;] = time(); </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>$insertSQL = $conn-&gt;AutoExecute($rs, $record, 'INSERT'); </pre></div>
  2703. <p class=MsoNormal>and an UPDATE with: </p>
  2704. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2705. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>$record[&quot;firstname&quot;] = &quot;Caroline&quot;; </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>$record[&quot;lastname&quot;] = &quot;Smith&quot;; # Update Caroline's lastname from Miranda to Smith </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>$insertSQL = $conn-&gt;AutoExecute($rs, $record, 'UPDATE', 'id = 1'); </pre></div>
  2706. <p>The rest of this section is out-of-date: </p>
  2707. <p>ADOdb 1.31 and later supports two new recordset functions: GetUpdateSQL( )
  2708. and GetInsertSQL( ). This allow you to perform a &quot;SELECT * FROM table
  2709. query WHERE...&quot;, make a copy of the $rs-&gt;fields, modify the fields, and
  2710. then generate the SQL to update or insert into the table automatically. </p>
  2711. <p>We show how the functions can be used when accessing a table with the
  2712. following fields: (ID, FirstName, LastName, Created). </p>
  2713. <p>Before these functions can be called, you need to initialize the recordset by
  2714. performing a select on the table. Idea and code by Jonathan Younger
  2715. jyounger#unilab.com. Since ADOdb 2.42, you can pass a table name instead of a
  2716. recordset into GetInsertSQL (in $rs), and it will generate an insert statement
  2717. for that table. </p>
  2718. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2719. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2720. style='background:#EEEEEE'>&lt;?<br>
  2721. #==============================================<br>
  2722. # SAMPLE GetUpdateSQL() and GetInsertSQL() code<br>
  2723. #==============================================<br>
  2724. include('adodb.inc.php');<br>
  2725. include('tohtml.inc.php');<br>
  2726. <br>
  2727. #==========================<br>
  2728. # This code tests an insert<br>
  2729. <br>
  2730. $sql = &quot;SELECT * FROM ADOXYZ WHERE id = -1&quot;; <br>
  2731. # Select an empty record from the database<br>
  2732. <br>
  2733. $conn = &amp;ADONewConnection(&quot;mysql&quot;);<span style='mso-spacerun:yes'>&nbsp; </span># create a connection<br>
  2734. $conn-&gt;debug=1;<br>
  2735. $conn-&gt;PConnect(&quot;localhost&quot;, &quot;admin&quot;, &quot;&quot;, &quot;test&quot;); # connect to MySQL, testdb<br>
  2736. $rs = $conn-&gt;Execute($sql); # Execute the query and get the empty recordset<br>
  2737. <br>
  2738. $record = array(); # Initialize an array to hold the record data to insert<br>
  2739. <br>
  2740. # Set the values for the fields in the record<br>
  2741. # Note that field names are case-insensitive<br>
  2742. $record[&quot;firstname&quot;] = &quot;Bob&quot;;<br>
  2743. $record[&quot;lastNamE&quot;] = &quot;Smith&quot;;<br>
  2744. $record[&quot;creaTed&quot;] = time();<br>
  2745. <br>
  2746. # Pass the empty recordset and the array containing the data to insert<br>
  2747. # into the GetInsertSQL function. The function will process the data and return<br>
  2748. # a fully formatted insert sql statement.<br>
  2749. $insertSQL = $conn-&gt;GetInsertSQL($rs, $record);<br>
  2750. <br>
  2751. $conn-&gt;Execute($insertSQL); # Insert the record into the database<br>
  2752. <br>
  2753. #==========================<br>
  2754. # This code tests an update<br>
  2755. <br>
  2756. $sql = &quot;SELECT * FROM ADOXYZ WHERE id = 1&quot;; <br>
  2757. # Select a record to update<br>
  2758. <br>
  2759. $rs = $conn-&gt;Execute($sql); # Execute the query and get the existing record to update<br>
  2760. <br>
  2761. $record = array(); # Initialize an array to hold the record data to update<br>
  2762. <br>
  2763. # Set the values for the fields in the record<br>
  2764. # Note that field names are case-insensitive<br>
  2765. $record[&quot;firstname&quot;] = &quot;Caroline&quot;;<br>
  2766. $record[&quot;LasTnAme&quot;] = &quot;Smith&quot;; # Update Caroline's lastname from Miranda to Smith<br>
  2767. <br>
  2768. # Pass the single record recordset and the array containing the data to update<br>
  2769. # into the GetUpdateSQL function. The function will process the data and return<br>
  2770. # a fully formatted update sql statement with the correct WHERE clause.<br>
  2771. # If the data has not changed, no recordset is returned<br>
  2772. $updateSQL = $conn-&gt;GetUpdateSQL($rs, $record);<br>
  2773. <br>
  2774. $conn-&gt;Execute($updateSQL); # Update the record in the database<br>
  2775. $conn-&gt;Close();<br>
  2776. ?&gt;</pre></div>
  2777. <p class=MsoNormal><a name="ADODB_FORCE_TYPE"></a><b>$ADODB_FORCE_TYPE</b></p>
  2778. <p>The behaviour of AutoExecute(), GetUpdateSQL() and GetInsertSQL() when
  2779. converting empty or null PHP variables to SQL is controlled by the global
  2780. $ADODB_FORCE_TYPE variable. Set it to one of the values below. Default is
  2781. ADODB_FORCE_VALUE (3): </p>
  2782. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2783. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2784. style='background:#EEEEEE'>0 = ignore empty fields. All empty fields in array are ignored.<br>
  2785. 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values.<br>
  2786. 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.<br>
  2787. 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and <br>
  2788. <span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>empty fields '' are set to empty '' sql values.<br>
  2789. <br>
  2790. define('ADODB_FORCE_IGNORE',0);<br>
  2791. define('ADODB_FORCE_NULL',1);<br>
  2792. define('ADODB_FORCE_EMPTY',2);<br>
  2793. define('ADODB_FORCE_VALUE',3);</pre></div>
  2794. <p>Thanks to Niko (nuko#mbnet.fi) for the $ADODB_FORCE_TYPE code. </p>
  2795. <p>Note: the constant ADODB_FORCE_NULLS is obsolete since 4.52 and is ignored.
  2796. Set $ADODB_FORCE_TYPE = ADODB_FORCE_NULL for equivalent behaviour. </p>
  2797. <p>Since 4.62, the table name to be used can be overridden by setting
  2798. $rs-&gt;tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
  2799. called. </p>
  2800. <h3>Example 8: Implementing Scrolling with Next and Previous<a name=ex8></a></h3>
  2801. <p>The following code creates a very simple recordset pager, where you can
  2802. scroll from page to page of a recordset.</p>
  2803. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2804. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2805. style='background:#EEEEEE'>include_once('../adodb.inc.php');<br>
  2806. include_once('../adodb-pager.inc.php');<br>
  2807. session_start();<br>
  2808. <br>
  2809. $db = NewADOConnection('mysql');<br>
  2810. <br>
  2811. $db-&gt;Connect('localhost','root','','xphplens');<br>
  2812. <br>
  2813. $sql = &quot;select * from adoxyz &quot;;<br>
  2814. <br>
  2815. $pager = new ADODB_Pager($db,$sql);<br>
  2816. $pager-&gt;Render($rows_per_page=5);</pre></div>
  2817. <p>This will create a basic record pager that looks like this: <a name=scr></a></p>
  2818. <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt;
  2819. background:beige'>
  2820. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  2821. <td style='padding:.75pt .75pt .75pt .75pt'>
  2822. <p class=MsoNormal><a href="#scr"><code><span style='font-size:10.0pt'>|&lt;</span></code></a>
  2823. &nbsp; <a href="#scr"><code><span style='font-size:10.0pt'>&lt;&lt;</span></code></a>
  2824. &nbsp; <a href="#scr"><code><span style='font-size:10.0pt'>&gt;&gt;</span></code></a>
  2825. &nbsp; <a href="#scr"><code><span style='font-size:10.0pt'>&gt;|</span></code></a>
  2826. &nbsp; </p>
  2827. </td>
  2828. </tr>
  2829. <tr style='mso-yfti-irow:1'>
  2830. <td style='padding:.75pt .75pt .75pt .75pt'>
  2831. <table class=MsoNormalTable border=1 cellpadding=0 width="100%"
  2832. style='width:100.0%;mso-cellspacing:1.5pt;background:white' cols=4>
  2833. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  2834. <td style='padding:.75pt .75pt .75pt .75pt'>
  2835. <p class=MsoNormal align=center style='text-align:center'><b>ID<o:p></o:p></b></p>
  2836. </td>
  2837. <td style='padding:.75pt .75pt .75pt .75pt'>
  2838. <p class=MsoNormal align=center style='text-align:center'><b>First Name<o:p></o:p></b></p>
  2839. </td>
  2840. <td style='padding:.75pt .75pt .75pt .75pt'>
  2841. <p class=MsoNormal align=center style='text-align:center'><b>Last Name<o:p></o:p></b></p>
  2842. </td>
  2843. <td style='padding:.75pt .75pt .75pt .75pt'>
  2844. <p class=MsoNormal align=center style='text-align:center'><b>Date Created<o:p></o:p></b></p>
  2845. </td>
  2846. </tr>
  2847. <tr style='mso-yfti-irow:1'>
  2848. <td style='padding:.75pt .75pt .75pt .75pt'>
  2849. <p class=MsoNormal align=right style='text-align:right'>36&nbsp;</p>
  2850. </td>
  2851. <td style='padding:.75pt .75pt .75pt .75pt'>
  2852. <p class=MsoNormal>Alan&nbsp;</p>
  2853. </td>
  2854. <td style='padding:.75pt .75pt .75pt .75pt'>
  2855. <p class=MsoNormal>Turing&nbsp;</p>
  2856. </td>
  2857. <td style='padding:.75pt .75pt .75pt .75pt'>
  2858. <p class=MsoNormal>Sat 06, Oct 2001&nbsp;</p>
  2859. </td>
  2860. </tr>
  2861. <tr style='mso-yfti-irow:2'>
  2862. <td style='padding:.75pt .75pt .75pt .75pt'>
  2863. <p class=MsoNormal align=right style='text-align:right'>37&nbsp;</p>
  2864. </td>
  2865. <td style='padding:.75pt .75pt .75pt .75pt'>
  2866. <p class=MsoNormal>Serena&nbsp;</p>
  2867. </td>
  2868. <td style='padding:.75pt .75pt .75pt .75pt'>
  2869. <p class=MsoNormal>Williams&nbsp;</p>
  2870. </td>
  2871. <td style='padding:.75pt .75pt .75pt .75pt'>
  2872. <p class=MsoNormal>Sat 06, Oct 2001&nbsp;</p>
  2873. </td>
  2874. </tr>
  2875. <tr style='mso-yfti-irow:3'>
  2876. <td style='padding:.75pt .75pt .75pt .75pt'>
  2877. <p class=MsoNormal align=right style='text-align:right'>38&nbsp;</p>
  2878. </td>
  2879. <td style='padding:.75pt .75pt .75pt .75pt'>
  2880. <p class=MsoNormal>Yat Sun&nbsp;</p>
  2881. </td>
  2882. <td style='padding:.75pt .75pt .75pt .75pt'>
  2883. <p class=MsoNormal>Sun&nbsp;</p>
  2884. </td>
  2885. <td style='padding:.75pt .75pt .75pt .75pt'>
  2886. <p class=MsoNormal>Sat 06, Oct 2001&nbsp;</p>
  2887. </td>
  2888. </tr>
  2889. <tr style='mso-yfti-irow:4'>
  2890. <td style='padding:.75pt .75pt .75pt .75pt'>
  2891. <p class=MsoNormal align=right style='text-align:right'>39&nbsp;</p>
  2892. </td>
  2893. <td style='padding:.75pt .75pt .75pt .75pt'>
  2894. <p class=MsoNormal>Wai Hun&nbsp;</p>
  2895. </td>
  2896. <td style='padding:.75pt .75pt .75pt .75pt'>
  2897. <p class=MsoNormal>See&nbsp;</p>
  2898. </td>
  2899. <td style='padding:.75pt .75pt .75pt .75pt'>
  2900. <p class=MsoNormal>Sat 06, Oct 2001&nbsp;</p>
  2901. </td>
  2902. </tr>
  2903. <tr style='mso-yfti-irow:5;mso-yfti-lastrow:yes'>
  2904. <td style='padding:.75pt .75pt .75pt .75pt'>
  2905. <p class=MsoNormal align=right style='text-align:right'>40&nbsp;</p>
  2906. </td>
  2907. <td style='padding:.75pt .75pt .75pt .75pt'>
  2908. <p class=MsoNormal>Steven&nbsp;</p>
  2909. </td>
  2910. <td style='padding:.75pt .75pt .75pt .75pt'>
  2911. <p class=MsoNormal>Oey&nbsp;</p>
  2912. </td>
  2913. <td style='padding:.75pt .75pt .75pt .75pt'>
  2914. <p class=MsoNormal>Sat 06, Oct 2001&nbsp;</p>
  2915. </td>
  2916. </tr>
  2917. </table>
  2918. <p class=MsoNormal><o:p></o:p></p>
  2919. </td>
  2920. </tr>
  2921. <tr style='mso-yfti-irow:2;mso-yfti-lastrow:yes'>
  2922. <td style='padding:.75pt .75pt .75pt .75pt'>
  2923. <p class=MsoNormal><span style='font-size:10.0pt'>Page 8/10</span></p>
  2924. </td>
  2925. </tr>
  2926. </table>
  2927. <p>The number of rows to display at one time is controled by the Render($rows)
  2928. method. If you do not pass any value to Render(), ADODB_Pager will default to
  2929. 10 records per page. </p>
  2930. <p>You can control the column titles by modifying your SQL (supported by most
  2931. databases): </p>
  2932. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2933. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2934. style='background:#EEEEEE'>$sql = 'select id as &quot;ID&quot;, firstname as &quot;First Name&quot;, <br>
  2935. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>lastname as &quot;Last Name&quot;, created as &quot;Date Created&quot; <br>
  2936. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>from adoxyz';</pre></div>
  2937. <p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example
  2938. included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>.
  2939. The ADODB_Pager code can be adapted by a programmer so that the text links can
  2940. be replaced by images, and the dull white background be replaced with more
  2941. interesting colors. </p>
  2942. <p>You can also allow display of html by setting $pager-&gt;htmlSpecialChars =
  2943. false. </p>
  2944. <p>Some of the code used here was contributed by Iván Oliva and Cornel G. </p>
  2945. <h3><a name=ex9></a>Example 9: Exporting in CSV or Tab-Delimited Format</h3>
  2946. <p>We provide some helper functions to export in comma-separated-value (CSV)
  2947. and tab-delimited formats:</p>
  2948. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2949. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><b>include_once('/path/to/adodb/toexport.inc.php');</b><br>
  2950. include_once('/path/to/adodb/adodb.inc.php');<br style='mso-special-character:
  2951. line-break'>
  2952. <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
  2953. <![endif]></pre><pre style='background:#EEEEEE'>$db = &amp;NewADOConnection('mysql');<br>
  2954. $db-&gt;Connect($server, $userid, $password, $database);<br>
  2955. <br>
  2956. $rs = $db-&gt;Execute('select fname as &quot;First Name&quot;, surname as &quot;Surname&quot; from table');<br>
  2957. <br>
  2958. print &quot;&lt;pre&gt;&quot;;<br>
  2959. print <b>rs2csv</b>($rs); # return a string, CSV format</pre>
  2960. <p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
  2961. background:#EEEEEE;border:none;mso-border-alt:solid #DDDDDD .75pt;padding:0cm;
  2962. mso-padding-alt:9.0pt 18.0pt 9.0pt 18.0pt'><span style='font-size:9.0pt;
  2963. font-family:"Courier New"'>print '&lt;hr&gt;';<br>
  2964. <br>
  2965. $rs-&gt;MoveFirst(); # note, some databases do not support MoveFirst<br>
  2966. print <b>rs2tab</b>($rs,<i>false</i>); # return a string, tab-delimited<br>
  2967. <span style='mso-tab-count:6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
  2968. style='mso-spacerun:yes'>&nbsp;</span># false == suppress field names in first line<o:p></o:p></span></p>
  2969. <pre style='background:#EEEEEE'>print '&lt;hr&gt;';<br>
  2970. $rs-&gt;MoveFirst();<br>
  2971. <b>rs2tabout</b>($rs); # send to stdout directly (there is also an rs2csvout function)<br>
  2972. print &quot;&lt;/pre&gt;&quot;;<br>
  2973. <br>
  2974. $rs-&gt;MoveFirst();<br>
  2975. $fp = fopen($path, &quot;w&quot;);<br>
  2976. if ($fp) {<br>
  2977. <span style='mso-spacerun:yes'>&nbsp; </span><b>rs2csvfile</b>($rs, $fp); # write to file (there is also an rs2tabfile function)<br>
  2978. <span style='mso-spacerun:yes'>&nbsp; </span>fclose($fp);<br>
  2979. }</pre></div>
  2980. <p>Carriage-returns or newlines are converted to spaces. Field names are
  2981. returned in the first line of text. Strings containing the delimiter character
  2982. are quoted with double-quotes. Double-quotes are double-quoted again. This
  2983. conforms to Excel import and export guide-lines. </p>
  2984. <p>All the above functions take as an optional last parameter, $addtitles which
  2985. defaults to <i>true</i>. When set to <i>false</i> field names in the first line
  2986. are suppressed. </p>
  2987. <h3>Example 10: Recordset Filters<a name=ex10></a></h3>
  2988. <p>Sometimes we want to pre-process all rows in a recordset before we use it.
  2989. For example, we want to ucwords all text in recordset. </p>
  2990. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  2991. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  2992. style='background:#EEEEEE'>include_once('adodb/rsfilter.inc.php');<br>
  2993. include_once('adodb/adodb.inc.php');<br>
  2994. <br>
  2995. // ucwords() every element in the recordset<br>
  2996. function do_ucwords(&amp;$arr,$rs)<br>
  2997. {<br>
  2998. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach($arr as $k =&gt; $v) {<br>
  2999. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$arr[$k] = ucwords($v);<br>
  3000. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br>
  3001. }<br>
  3002. <br>
  3003. $db = NewADOConnection('mysql');<br>
  3004. $db-&gt;PConnect('server','user','pwd','db');<br>
  3005. <br>
  3006. $rs = $db-&gt;Execute('select ... from table');<br>
  3007. $rs = <b>RSFilter</b>($rs,'do_ucwords');</pre></div>
  3008. <p>The <i>RSFilter</i> function takes 2 parameters, the recordset, and the name
  3009. of the <i>filter</i> function. It returns the processed recordset scrolled to
  3010. the first record. The <i>filter</i> function takes two parameters, the current
  3011. row as an array, and the recordset object. For future compatibility, you should
  3012. not use the original recordset object. </p>
  3013. <h3>Example 11:<a name=ex11></a> Smart Transactions</h3>
  3014. <p class=MsoNormal>The old way of doing transactions required you to use </p>
  3015. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3016. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3017. style='background:#EEEEEE'>$conn-&gt;<b>BeginTrans</b>();<br>
  3018. $ok = $conn-&gt;Execute($sql);<br>
  3019. if ($ok) $ok = $conn-&gt;Execute($sql2);<br>
  3020. if (!$ok) $conn-&gt;<b>RollbackTrans</b>();<br>
  3021. else $conn-&gt;<b>CommitTrans</b>();</pre></div>
  3022. <p class=MsoNormal>This is very complicated for large projects because you have
  3023. to track the error status. Smart Transactions is much simpler. You start a
  3024. smart transaction by calling StartTrans(): </p>
  3025. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3026. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3027. style='background:#EEEEEE'>$conn-&gt;<b>StartTrans</b>();<br>
  3028. $conn-&gt;Execute($sql);<br>
  3029. $conn-&gt;Execute($Sql2);<br>
  3030. $conn-&gt;<b>CompleteTrans</b>();</pre></div>
  3031. <p class=MsoNormal>CompleteTrans() detects when an SQL error occurs, and will
  3032. Rollback/Commit as appropriate. To specificly force a rollback even if no error
  3033. occured, use FailTrans(). Note that the rollback is done in CompleteTrans(),
  3034. and not in FailTrans(). </p>
  3035. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3036. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3037. style='background:#EEEEEE'>$conn-&gt;<b>StartTrans</b>();<br>
  3038. $conn-&gt;Execute($sql);<br>
  3039. if (!CheckRecords()) $conn-&gt;<strong><span style='font-family:"Courier New"'>FailTrans</span></strong>();<br>
  3040. $conn-&gt;Execute($Sql2);<br>
  3041. $conn-&gt;<b>CompleteTrans</b>();</pre></div>
  3042. <p>You can also check if a transaction has failed, using HasFailedTrans(),
  3043. which returns true if FailTrans() was called, or there was an error in the SQL
  3044. execution. Make sure you call HasFailedTrans() before you call CompleteTrans(),
  3045. as it is only works between StartTrans/CompleteTrans. </p>
  3046. <p>Lastly, StartTrans/CompleteTrans is nestable, and only the outermost block
  3047. is executed. In contrast, BeginTrans/CommitTrans/RollbackTrans is NOT nestable.
  3048. </p>
  3049. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3050. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>$conn-&gt;<strong><span
  3051. style='font-family:"Courier New"'>StartTrans</span></strong>();<br>
  3052. $conn-&gt;Execute($sql);<br>
  3053. <span style='mso-spacerun:yes'>&nbsp; </span>$conn-&gt;<strong><span
  3054. style='font-family:"Courier New"'>StartTrans</span></strong>();<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span><span
  3055. style='color:#006600'># ignored</span></pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>if (!CheckRecords()) $conn-&gt;FailTrans();</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>$conn-&gt;<strong><span
  3056. style='font-family:"Courier New"'>CompleteTrans</span></strong>(); <span
  3057. style='color:#006600'># ignored</span></pre><pre>$conn-&gt;Execute($Sql2);</pre><pre
  3058. style='background:#EEEEEE'>$conn-&gt;<strong><span style='font-family:"Courier New"'>CompleteTrans</span></strong>();</pre></div>
  3059. <p>Note: Savepoints are currently not supported. </p>
  3060. <h2><a name=errorhandling></a>Using Custom Error Handlers and PEAR_Error</h2>
  3061. <p>ADOdb supports PHP5 exceptions. Just include <i>adodb-exceptions.inc.php</i>
  3062. and you can now catch exceptions on errors as they occur. </p>
  3063. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3064. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3065. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>include(&quot;../adodb-exceptions.inc.php&quot;);</b> <br>
  3066. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>include(&quot;../adodb.inc.php&quot;);<span
  3067. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span> <br>
  3068. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>try { <br>
  3069. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db = NewADOConnection(&quot;oci8://scott:bad-password@mytns/&quot;); <br>
  3070. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>} catch (exception $e) { <br>
  3071. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var_dump($e); <br>
  3072. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>adodb_backtrace($e-&gt;gettrace());<br>
  3073. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>} </pre></div>
  3074. <p>ADOdb also provides two custom handlers which you can modify for your needs.
  3075. The first one is in the <b>adodb-errorhandler.inc.php</b> file. This makes use
  3076. of the standard PHP functions <a href="http://php.net/error_reporting">error_reporting</a>
  3077. to control what error messages types to display, and <a
  3078. href="http://php.net/trigger_error">trigger_error</a> which invokes the default
  3079. PHP error handler. </p>
  3080. <p>Including the above file will cause <i>trigger_error($errorstring,E_USER_ERROR)</i>
  3081. to be called when<br>
  3082. (a) Connect() or PConnect() fails, or <br>
  3083. (b) a function that executes SQL statements such as Execute() or SelectLimit()
  3084. has an error.<br>
  3085. (c) GenID() appears to go into an infinite loop. </p>
  3086. <p>The $errorstring is generated by ADOdb and will contain useful debugging
  3087. information similar to the error.log data generated below. This file
  3088. adodb-errorhandler.inc.php should be included before you create any
  3089. ADOConnection objects. </p>
  3090. <p>If you define error_reporting(0), no errors will be passed to the error
  3091. handler. If you set error_reporting(E_ALL), all errors will be passed to the
  3092. error handler. You still need to use <b>ini_set(&quot;display_errors&quot;,
  3093. &quot;0&quot; or &quot;1&quot;)</b> to control the display of errors. </p>
  3094. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3095. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?php<br>
  3096. <b>error_reporting(E_ALL); # pass any error messages triggered to error handler<br>
  3097. include('adodb-errorhandler.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c-&gt;PConnect('localhost','root','','northwind');</pre><pre>$rs=$c-&gt;Execute('select * from productsz'); #invalid table productsz');</pre><pre>if ($rs) rs2html($rs);</pre><pre>?&gt;</pre></div>
  3098. <p>If you want to log the error message, you can do so by defining the
  3099. following optional constants ADODB_ERROR_LOG_TYPE and ADODB_ERROR_LOG_DEST.
  3100. ADODB_ERROR_LOG_TYPE is the error log message type (see <a
  3101. href="http://php.net/error_log">error_log</a> in the PHP manual). In this case
  3102. we set it to 3, which means log to the file defined by the constant
  3103. ADODB_ERROR_LOG_DEST. </p>
  3104. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3105. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?php<br>
  3106. <b>error_reporting(E_ALL); # report all errors<br>
  3107. ini_set(&quot;display_errors&quot;, &quot;0&quot;); # but do not echo the errors<br>
  3108. define('ADODB_ERROR_LOG_TYPE',3);<br>
  3109. define('ADODB_ERROR_LOG_DEST','C:/errors.log');<br>
  3110. include('adodb-errorhandler.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre><o:p>&nbsp;</o:p></pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c-&gt;PConnect('localhost','root','','northwind');</pre><pre>$rs=$c-&gt;Execute('select * from productsz'); ## invalid table productsz</pre><pre>if ($rs) rs2html($rs);</pre><pre>?&gt;</pre></div>
  3111. <p class=MsoNormal>The following message will be logged in the error.log file: </p>
  3112. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3113. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3114. style='background:#EEEEEE'>(2001-10-28 14:20:38) mysql error: [1146: Table 'northwind.productsz' doesn't exist] in<br>
  3115. <span style='mso-spacerun:yes'>&nbsp;</span>EXECUTE(&quot;select * from productsz&quot;)</pre></div>
  3116. <h3>PEAR_ERROR</h3>
  3117. <p class=MsoNormal>The second error handler is <b>adodb-errorpear.inc.php</b>.
  3118. This will create a PEAR_Error derived object whenever an error occurs. The last
  3119. PEAR_Error object created can be retrieved using ADODB_Pear_Error(). </p>
  3120. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3121. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>&lt;?php<br>
  3122. <b>include('adodb-errorpear.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c-&gt;PConnect('localhost','root','','northwind');</pre><pre>$rs=$c-&gt;Execute('select * from productsz'); #invalid table productsz');</pre><pre>if ($rs) rs2html($rs);</pre><pre>else {</pre><pre><span
  3123. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>$e = ADODB_Pear_Error();<br>
  3124. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>echo '&lt;p&gt;',$e-&gt;message,'&lt;/p&gt;';</b></pre><pre>}</pre><pre>?&gt;</pre></div>
  3125. <p>You can use a PEAR_Error derived class by defining the constant
  3126. ADODB_PEAR_ERROR_CLASS before the adodb-errorpear.inc.php file is included. For
  3127. easy debugging, you can set the default error handler in the beginning of the
  3128. PHP script to PEAR_ERROR_DIE, which will cause an error message to be printed,
  3129. then halt script execution: </p>
  3130. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3131. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3132. style='background:#EEEEEE'>include('PEAR.php');<br>
  3133. PEAR::setErrorHandling('PEAR_ERROR_DIE');</pre></div>
  3134. <p>Note that we do not explicitly return a PEAR_Error object to you when an
  3135. error occurs. We return false instead. You have to call ADODB_Pear_Error() to
  3136. get the last error or use the PEAR_ERROR_DIE technique. </p>
  3137. <h3>MetaError and MetaErrMsg</h3>
  3138. <p>If you need error messages that work across multiple databases, then use <a
  3139. href="#metaerror">MetaError()</a>, which returns a virtualized error number,
  3140. based on PEAR DB's error number system, and <a href="#metaerrmsg">MetaErrMsg()</a>.
  3141. </p>
  3142. <h4>Error Messages</h4>
  3143. <p>Error messages are outputted using the static method
  3144. ADOConnnection::outp($msg,$newline=true). By default, it sends the messages to
  3145. the client. You can override this to perform error-logging. </p>
  3146. <h2><a name=dsn></a>Data Source Names</h2>
  3147. <p>We now support connecting using PEAR style DSN's. A DSN is a connection
  3148. string of the form:</p>
  3149. <p>$dsn = <i>&quot;$driver://$username:$password@$hostname/$databasename&quot;</i>;</p>
  3150. <p>An example:</p>
  3151. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3152. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3153. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$username = 'root';<br>
  3154. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$password = '';<br>
  3155. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$hostname = 'localhost';<br>
  3156. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$databasename = 'xphplens';<br>
  3157. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$driver = 'mysql';<br>
  3158. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$dsn = &quot;$driver://$username:$password@$hostname/$databasename&quot;<br>
  3159. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$db = NewADOConnection(); <br>
  3160. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># DB::Connect($dsn) also works if you include 'adodb/adodb-pear.inc.php' at the top<br>
  3161. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$rs = $db-&gt;query('select firstname,lastname from adoxyz');<br>
  3162. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$cnt = 0;<br>
  3163. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>while ($arr = $rs-&gt;fetchRow()) {<br>
  3164. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($arr); print &quot;&lt;br&gt;&quot;;<br>
  3165. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>}</pre></div>
  3166. <p><a href="#dsnsupport">More info and connection examples</a> on the DSN
  3167. format. </p>
  3168. <h2><a name=pear></a>PEAR Compatibility</h2>
  3169. <p class=MsoNormal>We support DSN's (see above), and the following functions: </p>
  3170. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3171. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><b><span style='mso-spacerun:yes'>&nbsp;</span>DB_Common</b></pre><pre> <span
  3172. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>query - returns PEAR_Error on error</pre><pre><span
  3173. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>limitQuery - return PEAR_Error on error</pre><pre><span
  3174. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>prepare - does not return PEAR_Error on error</pre><pre><span
  3175. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>execute - does not return PEAR_Error on error</pre><pre><span
  3176. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>setFetchMode - supports ASSOC and ORDERED</pre><pre><span
  3177. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>errorNative</pre><pre><span
  3178. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>quote</pre><pre><span style='mso-tab-count:
  3179. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>nextID</pre><pre><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>disconnect</pre><pre><span
  3180. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  3181. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>getOne</pre><pre><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>getAssoc</pre><pre><span
  3182. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>getRow</pre><pre><span
  3183. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>getCol</pre><pre><span
  3184. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><b> DB_Result</b></pre><pre> <span
  3185. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>numRows - returns -1 if not supported</pre><pre><span
  3186. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>numCols</pre><pre><span
  3187. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>fetchInto - does not support passing of fetchmode</pre><pre><span
  3188. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>fetchRows - does not support passing of fetchmode</pre><pre><span
  3189. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>free</pre></div>
  3190. <h2><a name=caching></a>Caching of Recordsets</h2>
  3191. <p>ADOdb now supports caching of recordsets in the file system using the
  3192. CacheExecute( ), CachePageExecute( ) and CacheSelectLimit( ) functions. There
  3193. are similar to the non-cache functions, except that they take a new first
  3194. parameter, $secs2cache. </p>
  3195. <p>An example: </p>
  3196. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3197. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3198. style='background:#EEEEEE'><b>include</b>('adodb.inc.php'); # load code common to ADOdb<br>
  3199. $ADODB_CACHE_DIR = '/usr/ADODB_cache';<br>
  3200. $<span style='color:#663300'>conn</span> = &amp;ADONewConnection('mysql');<span style='mso-spacerun:yes'>&nbsp; </span># create a connection<br>
  3201. $<span style='color:#663300'>conn</span>-&gt;PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
  3202. $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers';<br>
  3203. $<span style='color:#663300'>rs</span> = $<span style='color:#663300'>conn</span>-&gt;CacheExecute(15,$sql);</pre></div>
  3204. <p>The first parameter is the number of seconds to cache the query. Subsequent
  3205. calls to that query will used the cached version stored in $ADODB_CACHE_DIR. To
  3206. force a query to execute and flush the cache, call CacheExecute() with the
  3207. first parameter set to zero. Alternatively, use the CacheFlush($sql) call. </p>
  3208. <p>For the sake of security, we recommend you set <i>register_globals=off</i> in
  3209. php.ini if you are using $ADODB_CACHE_DIR.</p>
  3210. <p>In ADOdb 1.80 onwards, the secs2cache parameter is optional in
  3211. CacheSelectLimit() and CacheExecute(). If you leave it out, it will use the
  3212. $connection-&gt;cacheSecs parameter, which defaults to 60 minutes. The following
  3213. are equivalent: </p>
  3214. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3215. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp; </span># (1)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>$rs = $db-&gt;SelectLimit(30, 'select * from table', 10);</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;</span># (2)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>$db-&gt;cacheSsecs = 30;</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>$rs = $db-&gt;SelectLimit('select * from table', 10);</pre><pre
  3216. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span></pre><pre><span
  3217. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(...);<br>
  3218. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;cacheSecs = 3600*24; # cache 24 hours<br>
  3219. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $conn-&gt;CacheExecute('select * from table');</pre></div>
  3220. <p>Please note that magic_quotes_runtime should be turned off. Do not change
  3221. $ADODB_FETCH_MODE (or SetFetchMode) as the cached recordset will use the
  3222. $ADODB_FETCH_MODE set when the query was executed. <a name=memcache></a></p>
  3223. <h3><span style='mso-bookmark:memcache'>MemCache support</span></h3>
  3224. <p><span style='mso-bookmark:memcache'>You can also share cached recordsets on
  3225. a memcache server. The memcache API supports one or more pooled hosts. Only if
  3226. none of the pooled servers can be contacted will a connect error be generated.
  3227. Example below: </span></p>
  3228. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3229. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  3230. style='mso-bookmark:memcache'><o:p>&nbsp;</o:p></span></pre><pre><span
  3231. style='mso-bookmark:memcache'>$db = NewADOConnection($driver='mysql');</span></pre><pre><span
  3232. style='mso-bookmark:memcache'>$db-&gt;memCache = true;</span></pre><pre><span
  3233. style='mso-bookmark:memcache'>$db-&gt;memCacheHost = array($ip1, $ip2, $ip3); /// $db-&gt;memCacheHost = $ip1; will work too</span></pre><pre><span
  3234. style='mso-bookmark:memcache'>$db-&gt;memCachePort = 11211; /// this is default memCache port</span></pre><pre><span
  3235. style='mso-bookmark:memcache'>$db-&gt;memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)</span></pre><pre><span
  3236. style='mso-bookmark:memcache'><o:p>&nbsp;</o:p></span></pre><pre><span
  3237. style='mso-bookmark:memcache'>$db-&gt;Connect(...);</span></pre><pre><span
  3238. style='mso-bookmark:memcache'>$db-&gt;CacheExecute($sql);</span></pre></div>
  3239. <p><span style='mso-bookmark:memcache'>More info on memcache can be found at </span><a
  3240. href="http://www.danga.com/memcached/">http://www.danga.com/memcached/</a>. <a
  3241. name=cacheapi></a></p>
  3242. <h3><span style='mso-bookmark:cacheapi'>Caching API</span></h3>
  3243. <p><span style='mso-bookmark:cacheapi'>There is also a caching API since
  3244. 4.99/5.05. Two implementations of the API are already available providing file
  3245. and memcache support. </span></p>
  3246. <p><span style='mso-bookmark:cacheapi'>The new API for creating your custom
  3247. caching class uses 2 globals: </span></p>
  3248. <ul type=disc>
  3249. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  3250. mso-list:l8 level1 lfo8;tab-stops:list 36.0pt'><span style='mso-bookmark:
  3251. cacheapi'>$ADODB_CACHE_CLASS: name of caching class </span></li>
  3252. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  3253. mso-list:l8 level1 lfo8;tab-stops:list 36.0pt'><span style='mso-bookmark:
  3254. cacheapi'>$ADODB_CACHE: instance of $ADODB_CACHE_CLASS </span></li>
  3255. </ul>
  3256. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3257. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  3258. style='mso-bookmark:cacheapi'><o:p>&nbsp;</o:p></span></pre><pre><span
  3259. style='mso-bookmark:cacheapi'>include &quot;/path/to/adodb.inc.php&quot;;</span></pre><pre><span
  3260. style='mso-bookmark:cacheapi'>$ADODB_CACHE_CLASS = 'MyCacheClass';</span></pre><pre><span
  3261. style='mso-bookmark:cacheapi'><o:p>&nbsp;</o:p></span></pre><pre><span
  3262. style='mso-bookmark:cacheapi'>class MyCacheClass extends ADODB_Cache_File</span></pre><pre><span
  3263. style='mso-bookmark:cacheapi'>{</span></pre><pre><span style='mso-bookmark:
  3264. cacheapi'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var $createdir = false; // do not set this to true unless you use temp directories in cache path</span></pre><pre><span
  3265. style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>function writecache($filename, $contents,$debug=false){...}</span></pre><pre><span
  3266. style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>function &amp;readcache($filename, &amp;$err, $secs2cache, $rsClass){ ...}</span></pre><pre><span
  3267. style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span> :</span></pre><pre><span
  3268. style='mso-bookmark:cacheapi'>}</span></pre><pre><span style='mso-bookmark:
  3269. cacheapi'><o:p>&nbsp;</o:p></span></pre><pre><span style='mso-bookmark:cacheapi'>$DB = NewADOConnection($driver);</span></pre><pre><span
  3270. style='mso-bookmark:cacheapi'>$DB-&gt;Connect(...);<span style='mso-spacerun:yes'>&nbsp; </span>## MyCacheClass created here and stored in $ADODB_CACHE global variable.</span></pre><pre><span
  3271. style='mso-bookmark:cacheapi'><o:p>&nbsp;</o:p></span></pre><pre><span
  3272. style='mso-bookmark:cacheapi'>$data = $rs-&gt;CacheGetOne($sql); ## MyCacheClass is used here for caching...</span></pre></div>
  3273. <span style='mso-bookmark:cacheapi'></span>
  3274. <h2><a name=pivot></a>Pivot Tables</h2>
  3275. <p>Since ADOdb 2.30, we support the generation of SQL to create pivot tables,
  3276. also known as cross-tabulations. For further explanation read this DevShed <a
  3277. href="http://www.devshed.com/c/a/MySQL/MySQL-wizardry/1/">Cross-Tabulation tutorial</a>.
  3278. We assume that your database supports the SQL case-when expression. </p>
  3279. <p>In this example, we will use the Northwind database from Microsoft. In the
  3280. database, we have a products table, and we want to analyze this table by <i>suppliers
  3281. versus product categories</i>. We will place the suppliers on each row, and
  3282. pivot on categories. So from the table on the left, we generate the pivot-table
  3283. on the right:</p>
  3284. <div align=center>
  3285. <table class=MsoNormalTable border=0 cellpadding=0 style='mso-cellspacing:1.5pt;
  3286. mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
  3287. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
  3288. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3289. <div align=center>
  3290. <table class=MsoNormalTable border=1 cellpadding=0 width=142
  3291. style='width:106.5pt;mso-cellspacing:1.5pt;mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
  3292. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  3293. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3294. <p class=MsoNormal><i>Supplier</i></p>
  3295. </td>
  3296. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3297. <p class=MsoNormal><i>Category</i></p>
  3298. </td>
  3299. </tr>
  3300. <tr style='mso-yfti-irow:1'>
  3301. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3302. <p class=MsoNormal>supplier1</p>
  3303. </td>
  3304. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3305. <p class=MsoNormal>category1</p>
  3306. </td>
  3307. </tr>
  3308. <tr style='mso-yfti-irow:2'>
  3309. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3310. <p class=MsoNormal>supplier2</p>
  3311. </td>
  3312. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3313. <p class=MsoNormal>category1</p>
  3314. </td>
  3315. </tr>
  3316. <tr style='mso-yfti-irow:3;mso-yfti-lastrow:yes'>
  3317. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3318. <p class=MsoNormal>supplier2</p>
  3319. </td>
  3320. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3321. <p class=MsoNormal>category2</p>
  3322. </td>
  3323. </tr>
  3324. </table>
  3325. </div>
  3326. <p class=MsoNormal><o:p></o:p></p>
  3327. </td>
  3328. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3329. <p class=MsoNormal><span style='font-family:"Courier New"'>--&gt;</span></p>
  3330. </td>
  3331. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3332. <div align=center>
  3333. <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:
  3334. 1.5pt;mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
  3335. <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  3336. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3337. <p class=MsoNormal>&nbsp;</p>
  3338. </td>
  3339. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3340. <p class=MsoNormal><i>category1</i></p>
  3341. </td>
  3342. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3343. <p class=MsoNormal><i>category2</i></p>
  3344. </td>
  3345. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3346. <p class=MsoNormal><i>total</i></p>
  3347. </td>
  3348. </tr>
  3349. <tr style='mso-yfti-irow:1'>
  3350. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3351. <p class=MsoNormal><i>supplier1</i></p>
  3352. </td>
  3353. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3354. <p class=MsoNormal align=right style='text-align:right'>1</p>
  3355. </td>
  3356. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3357. <p class=MsoNormal align=right style='text-align:right'>0</p>
  3358. </td>
  3359. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3360. <p class=MsoNormal align=right style='text-align:right'>1</p>
  3361. </td>
  3362. </tr>
  3363. <tr style='mso-yfti-irow:2;mso-yfti-lastrow:yes'>
  3364. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3365. <p class=MsoNormal><i>supplier2</i></p>
  3366. </td>
  3367. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3368. <p class=MsoNormal align=right style='text-align:right'>1</p>
  3369. </td>
  3370. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3371. <p class=MsoNormal align=right style='text-align:right'>1</p>
  3372. </td>
  3373. <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
  3374. <p class=MsoNormal align=right style='text-align:right'>2</p>
  3375. </td>
  3376. </tr>
  3377. </table>
  3378. </div>
  3379. <p class=MsoNormal><o:p></o:p></p>
  3380. </td>
  3381. </tr>
  3382. </table>
  3383. </div>
  3384. <p>The following code will generate the SQL for a cross-tabulation: </p>
  3385. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3386. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3387. style='background:#EEEEEE'># Query the main &quot;product&quot; table<br>
  3388. # Set the rows to SupplierName<br>
  3389. # and the columns to the values of Categories<br>
  3390. # and define the joins to link to lookup tables <br>
  3391. # &quot;categories&quot; and &quot;suppliers&quot;<br>
  3392. #<br>
  3393. <span style='mso-spacerun:yes'>&nbsp;</span>include &quot;adodb/pivottable.inc.php&quot;;<br>
  3394. <span style='mso-spacerun:yes'>&nbsp;</span>$sql = PivotTableSQL(<br>
  3395. <span style='mso-spacerun:yes'>&nbsp;</span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$gDB,<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># adodb connection<br>
  3396. <span style='mso-spacerun:yes'>&nbsp;</span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'products p ,categories c ,suppliers s',<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># tables<br>
  3397. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'SupplierName',<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># rows (multiple fields allowed)<br>
  3398. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'CategoryName',<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># column to pivot on <br>
  3399. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where<br>
  3400. );</pre></div>
  3401. <p>This will generate the following SQL:</p>
  3402. <p><code><span style='font-size:10.0pt'>SELECT SupplierName, </span></code><span
  3403. style='font-size:10.0pt;font-family:"Courier New"'><br>
  3404. <code>SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS
  3405. &quot;Beverages&quot;, </code><br>
  3406. <code>SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS
  3407. &quot;Condiments&quot;, </code><br>
  3408. <code>SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS
  3409. &quot;Confections&quot;, </code><br>
  3410. <code>SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS
  3411. &quot;Dairy Products&quot;, </code><br>
  3412. <code>SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS
  3413. &quot;Grains/Cereals&quot;, </code><br>
  3414. <code>SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS
  3415. &quot;Meat/Poultry&quot;, </code><br>
  3416. <code>SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS
  3417. &quot;Produce&quot;, </code><br>
  3418. <code>SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS
  3419. &quot;Seafood&quot;, </code><br>
  3420. <code>SUM(1) as Total </code><br>
  3421. <code>FROM products p ,categories c ,suppliers s WHERE p.CategoryID =
  3422. c.CategoryID and s.SupplierID= p.SupplierID </code><br>
  3423. <code>GROUP BY SupplierName</code></span></p>
  3424. <p>You can also pivot on <i>numerical columns</i> and <i>generate totals</i> by
  3425. using ranges. This code was revised in ADODB 2.41 and is not backward
  3426. compatible. The second example shows this:</p>
  3427. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3428. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span style='mso-spacerun:yes'>&nbsp;</span>$sql = PivotTableSQL(<br>
  3429. <span style='mso-spacerun:yes'>&nbsp;</span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$gDB,<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># adodb connection<br>
  3430. <span style='mso-spacerun:yes'>&nbsp;</span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'products p ,categories c ,suppliers s',<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span># tables<br>
  3431. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'SupplierName',<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># rows (multiple fields allowed)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>array(<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># column ranges</pre><pre><span
  3432. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>' 0 '<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>=&gt; 'UnitsInStock &lt;= 0',</pre><pre><span
  3433. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;1 to 5&quot;<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>=&gt; '0 &lt; UnitsInStock and UnitsInStock &lt;= 5',</pre><pre><span
  3434. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;6 to 10&quot;<span style='mso-spacerun:yes'>&nbsp; </span>=&gt; '5 &lt; UnitsInStock and UnitsInStock &lt;= 10',</pre><pre><span
  3435. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;11 to 15&quot; =&gt; '10 &lt; UnitsInStock and UnitsInStock &lt;= 15',</pre><pre><span
  3436. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;16+&quot;<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>=&gt; '15 &lt; UnitsInStock'</pre><pre><span
  3437. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>),</pre><pre><span style='mso-tab-count:
  3438. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where</pre><pre><span
  3439. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'UnitsInStock',<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># sum this field</pre><pre><span
  3440. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'Sum '<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># sum label prefix</pre><pre>);</pre></div>
  3441. <p>Which generates: </p>
  3442. <p><code><span style='font-size:10.0pt'>SELECT SupplierName, </span></code><span
  3443. style='font-size:10.0pt;font-family:"Courier New"'><br>
  3444. <code>SUM(CASE WHEN UnitsInStock &lt;= 0 THEN UnitsInStock ELSE 0 END) AS
  3445. &quot;Sum 0 &quot;, </code><br>
  3446. <code>SUM(CASE WHEN 0 &lt; UnitsInStock and UnitsInStock &lt;= 5 THEN
  3447. UnitsInStock ELSE 0 END) AS &quot;Sum 1 to 5&quot;,</code><br>
  3448. <code>SUM(CASE WHEN 5 &lt; UnitsInStock and UnitsInStock &lt;= 10 THEN UnitsInStock
  3449. ELSE 0 END) AS &quot;Sum 6 to 10&quot;,</code><br>
  3450. <code>SUM(CASE WHEN 10 &lt; UnitsInStock and UnitsInStock &lt;= 15 THEN
  3451. UnitsInStock ELSE 0 END) AS &quot;Sum 11 to 15&quot;, </code><br>
  3452. <code>SUM(CASE WHEN 15 &lt; UnitsInStock THEN UnitsInStock ELSE 0 END) AS
  3453. &quot;Sum 16+&quot;, </code><br>
  3454. <code>SUM(UnitsInStock) AS &quot;Sum UnitsInStock&quot;, </code><br>
  3455. <code>SUM(1) as Total,</code><br>
  3456. <code>FROM products p ,categories c ,suppliers s WHERE p.CategoryID =
  3457. c.CategoryID and s.SupplierID= p.SupplierID </code><br>
  3458. <code>GROUP BY SupplierName</code></span></p>
  3459. <div class=MsoNormal align=center style='text-align:center'>
  3460. <hr size=2 width="100%" align=center>
  3461. </div>
  3462. <h1>Class Reference<a name=ref></a></h1>
  3463. <p>Function parameters with [ ] around them are optional.</p>
  3464. <h2>Global Variables</h2>
  3465. <h3><a name="adodb_countrecs"></a>$ADODB_COUNTRECS</h3>
  3466. <p>If the database driver API does not support counting the number of records
  3467. returned in a SELECT statement, the function RecordCount() is emulated when the
  3468. global variable $ADODB_COUNTRECS is set to true, which is the default. We
  3469. emulate this by buffering the records, which can take up large amounts of
  3470. memory for big recordsets. Set this variable to false for the best performance.
  3471. This variable is checked every time a query is executed, so you can selectively
  3472. choose which recordsets to count.</p>
  3473. <h3><a name="adodb_cache_dir"></a>$ADODB_CACHE_DIR</h3>
  3474. <p>If you are using recordset caching, this is the directory to save your
  3475. recordsets in. Define this before you call any caching functions such as
  3476. CacheExecute( ). We recommend setting <i>register_globals=off</i> in php.ini if
  3477. you use this feature for security reasons.</p>
  3478. <p>If you are using Unix and apache, you might need to set your cache directory
  3479. permissions to something similar to the following:</p>
  3480. <p>chown -R apache /path/to/adodb/cache<br>
  3481. chgrp -R apache /path/to/adodb/cache </p>
  3482. <h3><a name="adodb_ansi_padding_off"></a>$ADODB_ANSI_PADDING_OFF</h3>
  3483. <p>Determines whether to right trim CHAR fields (and also VARCHAR for
  3484. ibase/firebird). Set to true to trim. Default is false. Currently works for
  3485. oci8po, ibase and firebird drivers. Added in ADOdb 4.01. </p>
  3486. <h3><a name="adodb_lang"></a>$ADODB_LANG</h3>
  3487. <p>Determines the language used in MetaErrorMsg(). The default is 'en', for
  3488. English. To find out what languages are supported, see the files in
  3489. adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge. </p>
  3490. <h3><a name="adodb_fetch_mode"></a>$ADODB_FETCH_MODE</h3>
  3491. <p>This is a global variable that determines how arrays are retrieved by recordsets.
  3492. The recordset saves this value on creation (eg. in Execute( ) or SelectLimit(
  3493. )), and any subsequent changes to $ADODB_FETCH_MODE have no affect on existing
  3494. recordsets, only on recordsets created in the future.</p>
  3495. <p>The following constants are defined:</p>
  3496. <ul>
  3497. <li>ADODB_FETCH_DEFAULT = 0</li>
  3498. <li>ADODB_FETCH_NUM = 1</li>
  3499. <li>ADODB_FETCH_ASSOC = 2</li>
  3500. <li>ADODB_FETCH_BOTH = 3</li>
  3501. </ul>
  3502. <p>An example: </p>
  3503. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3504. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  3505. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_NUM;<br>
  3506. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs1 = $db-&gt;Execute('select * from table');<br>
  3507. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_ASSOC;<br>
  3508. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs2 = $db-&gt;Execute('select * from table');<br>
  3509. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs1-&gt;fields); # shows <i>array([0]=&gt;'v0',[1] =&gt;'v1')</i></pre><pre><span
  3510. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs2-&gt;fields); # shows <i>array(['col1']=&gt;'v0',['col2'] =&gt;'v1')</i></pre></div>
  3511. <p>As you can see in the above example, both recordsets store and use different
  3512. fetch modes based on the $ADODB_FETCH_MODE setting when the recordset was
  3513. created by Execute().</p>
  3514. <p>If no fetch mode is predefined, it defaults to
  3515. ADODB_FETCH_DEFAULT. The behaviour of this mode varies from driver to
  3516. driver, so do for portability reasons it is discouraged to rely on
  3517. ADODB_FETCH_DEFAULT; stick to ADODB_FETCH_NUM or ADODB_FETCH_ASSOC instead.
  3518. Note that many drivers do not support ADODB_FETCH_BOTH.</p>
  3519. <p><strong>SetFetchMode Function</strong></p>
  3520. <p>If you have multiple connection objects, and want to have different fetch
  3521. modes for each connection, then use <a href="#setfetchmode">SetFetchMode</a>.
  3522. Once this function is called for a connection object, that connection object
  3523. will ignore the global variable $ADODB_FETCH_MODE and will use the internal
  3524. fetchMode property exclusively.</p>
  3525. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3526. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  3527. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;SetFetchMode(ADODB_FETCH_NUM);<br>
  3528. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs1 = $db-&gt;Execute('select * from table');<br>
  3529. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;SetFetchMode(ADODB_FETCH_ASSOC);<br>
  3530. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs2 = $db-&gt;Execute('select * from table');<br>
  3531. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs1-&gt;fields); # shows <i>array([0]=&gt;'v0',[1] =&gt;'v1')</i></pre><pre
  3532. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($rs2-&gt;fields); # shows <i>array(['col1']=&gt;'v0',['col2'] =&gt;'v1')</i></pre></div>
  3533. <p>To retrieve the previous fetch mode, you can use check the $db-&gt;fetchMode
  3534. property, or use the return value of SetFetchMode( ). </p>
  3535. <p><a name="adodb_assoc_case"></a><strong>ADODB_ASSOC_CASE</strong></p>
  3536. <p>You can control the associative fetch case for certain drivers which behave
  3537. differently. For the <i>sybase, oci8, mssql, odbc and ibase</i> drivers (including
  3538. all those derived from them). Define the ADODB_ASSOC_CASE constant as appropriate to
  3539. change the case of the keys. The default is to use native case. Possible values are:</p>
  3540. <ul>
  3541. <li>ADODB_ASSOC_CASE_LOWER = 0 - $rs->fields['orderid']</li>
  3542. <li>ADODB_ASSOC_CASE_UPPER = 1 - $rs->fields['ORDERID']</li>
  3543. <li>ADODB_ASSOC_CASE_NATIVE = 2 - $rs->fields['OrderID'] (or whatever the RDBMS will return)</li>
  3544. </ul>
  3545. <p>Example: <pre>
  3546. include('adodb.inc.php');
  3547. define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_LOWER);
  3548. </pre></p>
  3549. <h3><a name="force_type"></a>$ADODB_FORCE_TYPE</h3>
  3550. <p>See the <a href="#ADODB_FORCE_TYPE">GetUpdateSQL tutorial</a>. </p>
  3551. <h3><a name="adodb_auto_quote"></a>$ADODB_QUOTE_FIELDNAMES</h3>
  3552. <p>Auto-quotes field names when using AutoExecute() when set to true. </p>
  3553. <p>Since 5.13, if $ADODB_QUOTE_FIELDNAMES is set to:
  3554. <ul>
  3555. <li>'UPPER' or true: uppercase field names. This is the default.
  3556. <li>'NATIVE' : use native case.
  3557. <li>'LOWER': lowercase field names.
  3558. </ul>
  3559. <p>&nbsp;</p>
  3560. <div class=MsoNormal align=center style='text-align:center'>
  3561. <hr size=2 width="100%" align=center>
  3562. </div>
  3563. <h2>ADOConnection<a name=adoconnection></a></h2>
  3564. <p>Object that performs the connection to the database, executes SQL statements
  3565. and has a set of utility functions for standardising the format of SQL
  3566. statements for issues such as concatenation and date formats.</p>
  3567. <h3>ADOConnection Fields</h3>
  3568. <p><b>databaseType</b>: Name of the database system we are connecting to. Eg. <b>odbc</b>
  3569. or <b>mssql</b> or <b>mysql</b>.</p>
  3570. <p><b>dataProvider</b>: The underlying mechanism used to connect to the
  3571. database. Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
  3572. <p><b>host: </b>Name of server or data source name (DSN) to connect to.</p>
  3573. <p><b>database</b>: Name of the database or to connect to. If ado is used, it
  3574. will hold the ado data provider.</p>
  3575. <p><b>user</b>: Login id to connect to database. Password is not saved for
  3576. security reasons.</p>
  3577. <p><b>raiseErrorFn</b>: Allows you to define an error handling function. See
  3578. adodb-errorhandler.inc.php for an example.</p>
  3579. <p><b>debug</b>: Set to <i>true</i> to make debug statements. Set to -99 to only display errors. Set to 99 to display debug statements and add a backtrace.</p>
  3580. <p><b>concat_operator</b>: Set to '+' or '||' normally. The operator used to
  3581. concatenate strings in SQL. Used by the <b><a href="#concat">Concat</a></b>
  3582. function.</p>
  3583. <p><b>fmtDate</b>: The format used by the <b><a href="#dbdate">DBDate</a></b>
  3584. function to send dates to the database. is '#Y-m-d#' for Microsoft Access, and
  3585. ''Y-m-d'' for MySQL.</p>
  3586. <p><b>fmtTimeStamp: </b>The format used by the <b><a href="#dbtimestamp">DBTimeStamp</a></b>
  3587. function to send timestamps to the database. </p>
  3588. <p><b>true</b>: The value used to represent true.Eg. '.T.'. for Foxpro, '1' for
  3589. Microsoft SQL.</p>
  3590. <p><b>false: </b>The value used to represent false. Eg. '.F.'. for Foxpro, '0'
  3591. for Microsoft SQL.</p>
  3592. <p><b>replaceQuote</b>: The string used to escape quotes. Eg. double
  3593. single-quotes for Microsoft SQL, and backslash-quote for MySQL. Used by <a
  3594. href="#qstr">qstr</a>.</p>
  3595. <p><b>autoCommit</b>: indicates whether automatic commit is enabled. Default is
  3596. true.</p>
  3597. <p><b>charSet</b>: set the default charset to use. Currently only
  3598. interbase/firebird supports this.</p>
  3599. <p><b>dialect</b>: set the default sql dialect to use. Currently only interbase/firebird
  3600. supports this.</p>
  3601. <p><b>role</b>: set the role. Currently only interbase/firebird supports this.</p>
  3602. <p><b>metaTablesSQL</b>: SQL statement to return a list of available tables.
  3603. Eg. <i>SHOW TABLES</i> in MySQL.</p>
  3604. <p><b>genID</b>: The latest id generated by GenID() if supported by the
  3605. database.</p>
  3606. <p><b>cacheSecs</b>: The number of seconds to cache recordsets if
  3607. CacheExecute() or CacheSelectLimit() omit the $secs2cache parameter. Defaults
  3608. to 60 minutes.</p>
  3609. <p><b>sysDate</b>: String that holds the name of the database function to call
  3610. to get the current date. Useful for inserts and updates.</p>
  3611. <p><b>sysTimeStamp</b>: String that holds the name of the database function to
  3612. call to get the current timestamp/datetime value.</p>
  3613. <p><b>leftOuter</b>: String that holds operator for left outer join, if known.
  3614. Otherwise set to false.</p>
  3615. <p><b>rightOuter</b>: String that holds operator for left outer join, if known.
  3616. Otherwise set to false.</p>
  3617. <p><b>ansiOuter</b>: Boolean that if true indicates that ANSI style outer joins
  3618. are permitted. Eg. <i>select * from table1 left join table2 on p1=p2.</i></p>
  3619. <p><b>connectSID</b>: Boolean that indicates whether to treat the $database
  3620. parameter in connects as the SID for the oci8 driver. Defaults to false. Useful
  3621. for Oracle 8.0.5 and earlier.</p>
  3622. <p><b>autoRollback</b>: Persistent connections are auto-rollbacked in PConnect(
  3623. ) if this is set to true. Default is false.</p>
  3624. <div class=MsoNormal align=center style='text-align:center'>
  3625. <hr size=2 width="100%" align=center>
  3626. </div>
  3627. <h3>ADOConnection Main Functions</h3>
  3628. <p><b>ADOConnection( )</b></p>
  3629. <p>Constructor function. Do not call this directly. Use ADONewConnection( )
  3630. instead.</p>
  3631. <p><b>Connect<a name=connect></a>($host,[$user],[$password],[$database])</b></p>
  3632. <p>Non-persistent connect to data source or server $<b>host</b>, using userid $<b>user
  3633. </b>and password $<b>password</b>. If the server supports multiple databases,
  3634. connect to database $<b>database</b>. </p>
  3635. <p>Returns true/false depending on connection success. Since 4.23, null is
  3636. returned if the extension is not loaded.</p>
  3637. <p><st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City> Note: If
  3638. you are using a Microsoft ADO and not OLEDB, you can set the $database
  3639. parameter to the OLEDB data provider you are using.</p>
  3640. <p>PostgreSQL: An alternative way of connecting to the database is to pass the
  3641. standard PostgreSQL connection string in the first parameter $host, and the
  3642. other parameters will be ignored.</p>
  3643. <p>For Oracle and Oci8, there are two ways to connect. First is to use the TNS
  3644. name defined in your local tnsnames.ora (or ONAMES or HOSTNAMES). Place the
  3645. name in the $database field, and set the $host field to false. Alternatively,
  3646. set $host to the server, and $database to the database SID, this bypassed
  3647. tnsnames.ora. </p>
  3648. <p>Examples: </p>
  3649. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3650. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3651. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span># $oraname in tnsnames.ora/ONAMES/HOSTNAMES<br>
  3652. <span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;Connect(false, 'scott', 'tiger', $oraname); <br>
  3653. <span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora</pre></div>
  3654. <p>There are many examples of connecting to a database. See <a
  3655. href="#connect_ex">Connection Examples</a> for many examples. </p>
  3656. <p><b>PConnect<a name=pconnect></a>($host,[$user],[$password],[$database])</b></p>
  3657. <p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b>
  3658. and password $<b>password</b>. If the server supports multiple databases,
  3659. connect to database $<b>database</b>.</p>
  3660. <p>We now perform a rollback on persistent connection for selected databases
  3661. since 2.21, as advised in the PHP manual. See change log or source code for
  3662. which databases are affected. </p>
  3663. <p>Returns true/false depending on connection. Since 4.23, 0 is returned if the
  3664. extension is not loaded. See Connect( ) above for more info.</p>
  3665. <p>Since ADOdb 2.21, we also support autoRollback. If you set:</p>
  3666. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3667. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3668. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span>$conn = &amp;NewADOConnection('mysql');<br>
  3669. <span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;autoRollback = true; # default is false<br>
  3670. <span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;PConnect(...); # rollback here</pre></div>
  3671. <p>Then when doing a persistent connection with PConnect( ), ADOdb will perform
  3672. a rollback first. This is because it is documented that PHP is not guaranteed
  3673. to rollback existing failed transactions when persistent connections are used.
  3674. This is implemented in Oracle, MySQL, PgSQL, MSSQL, ODBC currently. </p>
  3675. <p>Since ADOdb 3.11, you can force non-persistent connections even if PConnect
  3676. is called by defining the constant ADODB_NEVER_PERSIST before you call
  3677. PConnect. </p>
  3678. <p>Since 4.23, null is returned if the extension is not loaded. </p>
  3679. <p><b>NConnect<a name=nconnect></a>($host,[$user],[$password],[$database])</b></p>
  3680. <p>Always force a new connection. In contrast, PHP sometimes reuses connections
  3681. when you use Connect() or PConnect(). Currently works only on mysql (PHP 4.3.0
  3682. or later), postgresql and oci8-derived drivers. For other drivers, NConnect()
  3683. works like Connect().</p>
  3684. <p><b>IsConnected( )</b><a name=isconnected></a></p>
  3685. <p>Returns true if connected to database. Added in 4.53. </p>
  3686. <p><b>Execute<a name=execute></a>($sql,$inputarr=false)</b></p>
  3687. <p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet
  3688. if successful. Note that a record set is always returned on success, even if we
  3689. are executing an insert or update statement. You can also pass in $sql a
  3690. statement prepared in <a href="#prepare">Prepare()</a>.</p>
  3691. <p>Returns derived class of ADORecordSet. Eg. if connecting via mysql, then
  3692. ADORecordSet_mysql would be returned. False is returned if there was an error
  3693. in executing the sql.</p>
  3694. <p>The $inputarr parameter can be used for binding variables to parameters.
  3695. Below is an Oracle example:</p>
  3696. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3697. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3698. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;Execute(&quot;SELECT * FROM TABLE WHERE COND=:val&quot;, array('val'=&gt; $val));<br>
  3699. <span style='mso-spacerun:yes'>&nbsp;</span></pre></div>
  3700. <p>Another example, using ODBC,which uses the ? convention:</p>
  3701. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3702. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3703. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span>$conn-&gt;Execute(&quot;SELECT * FROM TABLE WHERE COND=?&quot;, array($val));</pre></div>
  3704. <p class=MsoNormal><a name=binding></a><i>Binding variables</i></p>
  3705. <p>Variable binding speeds the compilation and caching of SQL statements,
  3706. leading to higher performance. Currently Oracle, Interbase and ODBC supports
  3707. variable binding. Interbase/ODBC style ? binding is emulated in databases that
  3708. do not support binding. Note that you do not have to quote strings if you use
  3709. binding. </p>
  3710. <p>Variable binding in the odbc, interbase and oci8po drivers. </p>
  3711. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3712. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3713. style='background:#EEEEEE'>$rs = $db-&gt;Execute('select * from table where val=?', array('10'));</pre></div>
  3714. <p class=MsoNormal>Variable binding in the oci8 driver: </p>
  3715. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3716. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3717. style='background:#EEEEEE'>$rs = $db-&gt;Execute('select name from table where val=:key', <br>
  3718. <span style='mso-spacerun:yes'>&nbsp; </span>array('key' =&gt; 10));</pre></div>
  3719. <p class=MsoNormal><a name=bulkbind></a><i>Bulk binding</i> </p>
  3720. <p>Since ADOdb 3.80, we support bulk binding in Execute(), in which you pass in
  3721. a 2-dimensional array to be bound to an INSERT/UPDATE or DELETE statement. And since ADOdb 5.11 this is
  3722. disabled by default due to security issues. To enable, set $conn->bulkBind = true. </p>
  3723. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3724. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3725. style='background:#EEEEEE'>$arr = array(<br>
  3726. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('Ahmad',32),<br>
  3727. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('Zulkifli', 24),<br>
  3728. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('Rosnah', 21)<br>
  3729. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>);<br>
  3730. $ok = $db-&gt;Execute('insert into table (name,age) values (?,?)',$arr);</pre></div>
  3731. <p>This provides very high performance as the SQL statement is prepared first.
  3732. The prepared statement is executed repeatedly for each array row until all rows
  3733. are completed, or until the first error. Very useful for importing data. </p>
  3734. <p><b>CacheExecute<a name=cacheexecute></a>([$secs2cache,]$sql,$inputarr=false)</b></p>
  3735. <p>Similar to Execute, except that the recordset is cached for $secs2cache
  3736. seconds in the $ADODB_CACHE_DIR directory, and $inputarr only accepts
  3737. 1-dimensional arrays. If CacheExecute() is called again with the same $sql,
  3738. $inputarr, and also the same database, same userid, and the cached recordset
  3739. has not expired, the cached recordset is returned. </p>
  3740. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3741. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3742. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span>include('adodb.inc.php'); <br>
  3743. <span style='mso-spacerun:yes'>&nbsp; </span>include('tohtml.inc.php');<br>
  3744. <span style='mso-spacerun:yes'>&nbsp; </span>$ADODB_<b>CACHE_DIR</b> = '/usr/local/ADOdbcache';<br>
  3745. <span style='mso-spacerun:yes'>&nbsp; </span>$conn = &amp;ADONewConnection('mysql'); <br>
  3746. <span style='mso-spacerun:yes'>&nbsp; </span>$conn-&gt;PConnect('localhost','userid','password','database');<br>
  3747. <span style='mso-spacerun:yes'>&nbsp; </span>$rs = $conn-&gt;<b>CacheExecute</b>(15, 'select * from table'); # cache 15 secs<br>
  3748. <span style='mso-spacerun:yes'>&nbsp; </span>rs2html($rs); /* recordset to html table */<span style='mso-spacerun:yes'>&nbsp; </span></pre></div>
  3749. <p>Alternatively, since ADOdb 1.80, the $secs2cache parameter is optional:</p>
  3750. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3751. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3752. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(...);<br>
  3753. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;cacheSecs = 3600*24; // cache 24 hours<br>
  3754. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $conn-&gt;CacheExecute('select * from table');</pre></div>
  3755. <p class=MsoNormal>If $secs2cache is omitted, we use the value in
  3756. $connection-&gt;cacheSecs (default is 3600 seconds, or 1 hour). Use
  3757. CacheExecute() only with SELECT statements. </p>
  3758. <p>Performance note: I have done some benchmarks and found that they vary so
  3759. greatly that it's better to talk about when caching is of benefit. When your
  3760. database server is <i>much slower </i>than your Web server or the database is <i>very
  3761. overloaded </i>then ADOdb's caching is good because it reduces the load on your
  3762. database server. If your database server is lightly loaded or much faster than
  3763. your Web server, then caching could actually reduce performance. </p>
  3764. <p><b>ExecuteCursor<a name=executecursor></a>($sql,$cursorName='rs',$parameters=false)</b></p>
  3765. <p>Execute an Oracle stored procedure, and returns an Oracle REF cursor
  3766. variable as a regular ADOdb recordset. Does not work with any other database
  3767. except oci8. Thanks to Robert Tuttle for the design. </p>
  3768. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3769. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3770. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>$db = ADONewConnection(&quot;oci8&quot;); <br>
  3771. <span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>$db-&gt;Connect(&quot;foo.com:1521&quot;, &quot;uid&quot;, &quot;pwd&quot;, &quot;FOO&quot;); <br>
  3772. <span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>$rs = $db-&gt;ExecuteCursor(&quot;begin :cursorvar := getdata(:param1); end;&quot;, <br>
  3773. <span style='mso-tab-count:5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'cursorvar',<br>
  3774. <span style='mso-tab-count:5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('param1'=&gt;10)); <br>
  3775. <span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span># $rs is now just like any other ADOdb recordset object<br>
  3776. <span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>rs2html($rs);</pre></div>
  3777. <p>ExecuteCursor() is a helper function that does the following internally: </p>
  3778. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3779. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3780. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$stmt = $db-&gt;Prepare(&quot;begin :cursorvar := getdata(:param1); end;&quot;, true); <br>
  3781. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Parameter($stmt, $cur, 'cursorvar', false, -1, OCI_B_CURSOR);<br>
  3782. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $db-&gt;Execute($stmt,$bindarr);</pre></div>
  3783. <p>ExecuteCursor only accepts 1 out parameter. So if you have 2 out parameters,
  3784. use: </p>
  3785. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3786. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3787. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$vv = 'A%';<br>
  3788. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$stmt = $db-&gt;PrepareSP(&quot;BEGIN list_tabs(:crsr,:tt); END;&quot;);<br>
  3789. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;OutParameter($stmt, $cur, 'crsr', -1, OCI_B_CURSOR);<br>
  3790. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;OutParameter($stmt, $vv, 'tt', 32); # return varchar(32)<br>
  3791. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$arr = $db-&gt;GetArray($stmt);<br>
  3792. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print_r($arr);<br>
  3793. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>echo &quot; val = $vv&quot;; ## outputs 'TEST'</pre></div>
  3794. <p class=MsoNormal>for the following PL/SQL: </p>
  3795. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3796. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3797. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;<br>
  3798. <br>
  3799. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PROCEDURE list_tabs(tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS<br>
  3800. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>BEGIN<br>
  3801. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;<br>
  3802. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tablenames := 'TEST';<br>
  3803. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>END list_tabs;</pre></div>
  3804. <p><b>SelectLimit<a name=selectlimit></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
  3805. <p>Returns a recordset if successful. Returns false otherwise. Performs a
  3806. select statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows
  3807. OFFSET $offset clause.</p>
  3808. <p>In PostgreSQL, SELECT * FROM TABLE LIMIT 3 will return the first 3 records
  3809. only. The equivalent is <code><span style='font-size:10.0pt'>$connection-&gt;SelectLimit('SELECT
  3810. * FROM TABLE',3)</span></code>. This functionality is simulated for databases
  3811. that do not possess this feature.</p>
  3812. <p>And SELECT * FROM TABLE LIMIT 3 OFFSET 2 will return records 3, 4 and 5 (eg.
  3813. after record 2, return 3 rows). The equivalent in ADOdb is <code><span
  3814. style='font-size:10.0pt'>$connection-&gt;SelectLimit('SELECT * FROM TABLE',3,2)</span></code>.</p>
  3815. <p>Note that this is the <i>opposite</i> of MySQL's LIMIT clause. You can also
  3816. set <code><span style='font-size:10.0pt'>$connection-&gt;SelectLimit('SELECT *
  3817. FROM TABLE',-1,10)</span></code> to get rows 11 to the last row.</p>
  3818. <p>The last parameter $inputarr is for databases that support variable binding
  3819. such as Oracle oci8. This substantially reduces SQL compilation overhead. Below
  3820. is an Oracle example:</p>
  3821. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3822. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3823. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;SelectLimit(&quot;SELECT * FROM TABLE WHERE COND=:val&quot;, 100,-1,array('val'=&gt; $val));<br>
  3824. <span style='mso-spacerun:yes'>&nbsp;</span></pre></div>
  3825. <p>The oci8po driver (oracle portable driver) uses the more standard bind
  3826. variable of ?: </p>
  3827. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3828. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3829. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span>$conn-&gt;SelectLimit(&quot;SELECT * FROM TABLE WHERE COND=?&quot;, 100,-1,array('val'=&gt; $val));</pre></div>
  3830. <p>Ron Wilson reports that SelectLimit does not work with UNIONs. </p>
  3831. <p><b>CacheSelectLimit<a name=cacheselectlimit></a>([$secs2cache,] $sql,
  3832. $numrows=-1,$offset=-1,$inputarr=false)</b></p>
  3833. <p>Similar to SelectLimit, except that the recordset returned is cached for
  3834. $secs2cache seconds in the $ADODB_CACHE_DIR directory. </p>
  3835. <p>Since 1.80, $secs2cache has been optional, and you can define the caching
  3836. time in $connection-&gt;cacheSecs.</p>
  3837. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3838. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3839. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Connect(...);<br>
  3840. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$conn-&gt;cacheSecs = 3600*24; // cache 24 hours<br>
  3841. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs = $conn-&gt;CacheSelectLimit('select * from table',10);</pre></div>
  3842. <p><b>CacheFlush<a name=cacheflush></a>($sql=false,$inputarr=false)</b></p>
  3843. <p>Flush (delete) any cached recordsets for the SQL statement $sql in
  3844. $ADODB_CACHE_DIR. </p>
  3845. <p>If no parameter is passed in, then all adodb_*.cache files are deleted. </p>
  3846. <p>CacheSelectLimit() rewrites the SQL query, so you won't be able to pass the
  3847. SQL to CacheFlush. In this case, to flush the cached SQL recordset returned by
  3848. CacheSelectLimit(), set $secs2cache to -1: </p>
  3849. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3850. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  3851. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;CacheSelectLimit(-1, $sql, $nrows);</pre></div>
  3852. <p>If you want to flush all cached recordsets manually, execute the following
  3853. PHP code (works only under Unix): <br>
  3854. <code><span style='font-size:10.0pt'>&nbsp; system(&quot;rm -f `find
  3855. &quot;.$ADODB_CACHE_DIR.&quot; -name adodb_*.cache`&quot;);</span></code></p>
  3856. <p>For general cleanup of all expired files, you should use
  3857. <a href="http://www.adminschoice.com/crontab-quick-reference">crontab</a> on Unix,
  3858. or at.exe on Windows, and a shell script similar to the following:
  3859. <span style='font-family:"Courier New"'><br>
  3860. #------------------------------------------------------ <br>
  3861. # This particular example deletes files in the TMPPATH <br>
  3862. # directory with the string &quot;.cache&quot; in their name that <br>
  3863. # are more than 7 days old. <br>
  3864. #------------------------------------------------------ <br>
  3865. AGED=7 <br>
  3866. find ${TMPPATH} -mtime +$AGED | grep &quot;\.cache&quot; | xargs rm -f </span></p>
  3867. <p><b>MetaError<a name=metaerror></a>($errno=false)</b></p>
  3868. <p>Returns a virtualized error number, based on PEAR DB's error number system.
  3869. You might need to include adodb-error.inc.php before you call this function.
  3870. The parameter $errno is the native error number you want to convert. If you do
  3871. not pass any parameter, MetaError will call ErrorNo() for you and convert it.
  3872. If the error number cannot be virtualized, MetaError will return -1 (DB_ERROR).</p>
  3873. <p><b>MetaErrorMsg<a name=metaerrormsg></a>($errno)</b></p>
  3874. <p>Pass the error number returned by MetaError() for the equivalent textual
  3875. error message.</p>
  3876. <p><b>ErrorMsg<a name=errormsg></a>()</b></p>
  3877. <p>Returns the last status or error message. The error message is reset after
  3878. every call to Execute(). </p>
  3879. <p>This can return a string even if no error occurs. In general you do not need
  3880. to call this function unless an ADOdb function returns false on an error. </p>
  3881. <p>Note: If <b>debug</b> is enabled, the SQL error message is always displayed
  3882. when the <b>Execute</b> function is called.</p>
  3883. <p><b>ErrorNo<a name=errorno></a>()</b></p>
  3884. <p>Returns the last error number. The error number is reset after every call to
  3885. Execute(). If 0 is returned, no error occurred. </p>
  3886. <p>Note that old versions of PHP (pre 4.0.6) do not support error number for
  3887. ODBC. In general you do not need to call this function unless an ADOdb function
  3888. returns false on an error.</p>
  3889. <p><b>IgnoreErrors<a name=ignoreerrors></a>($saveErrHandlers)</b></p>
  3890. <p>Allows you to ignore errors so that StartTrans()/CompleteTrans() is not
  3891. affected, nor is the default error handler called if an error occurs. Useful
  3892. when you want to check if a field or table exists in a database without
  3893. invoking an error if it does not exist. </p>
  3894. <p>Usage: </p>
  3895. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3896. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre>$saveErrHandlers = $conn-&gt;IgnoreErrors();</pre><pre>$rs = $conn-&gt;Execute(&quot;select field from some_table_that_might_not_exist&quot;);</pre><pre>$conn-&gt;IgnoreErrors($saveErrHandlers);</pre></div>
  3897. <p>Warning: do not call StartTrans()/CompleteTrans() inside a code block that
  3898. is using IgnoreErrors(). </p>
  3899. <p><b>SetFetchMode<a name=setfetchmode></a>($mode)</b></p>
  3900. <p>Sets the current fetch mode for the connection and stores it in
  3901. $db-&gt;fetchMode. Legal modes are ADODB_FETCH_ASSOC and ADODB_FETCH_NUM. For
  3902. more info, see <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>.</p>
  3903. <p>Returns the previous fetch mode, which could be false if SetFetchMode( ) has
  3904. not been called before.</p>
  3905. <p><b>CreateSequence<a name=createseq></a>($seqName = 'adodbseq',$startID=1)</b></p>
  3906. <p>Create a sequence. The next time GenID( ) is called, the value returned will
  3907. be $startID. Added in 2.60. </p>
  3908. <p><b>DropSequence<a name=dropseq></a>($seqName = 'adodbseq')</b></p>
  3909. <p>Delete a sequence. Added in 2.60. </p>
  3910. <p><b>GenID<a name=genid></a>($seqName = 'adodbseq',$startID=1)</b></p>
  3911. <p>Generate a sequence number . Works for interbase, mysql, postgresql, oci8,
  3912. oci8po, mssql, ODBC based (access,vfp,db2,etc) drivers currently. Uses $seqName
  3913. as the name of the sequence. GenID() will automatically create the sequence for
  3914. you if it does not exist (provided the userid has permission to do so).
  3915. Otherwise you will have to create the sequence yourself. </p>
  3916. <p>If your database driver emulates sequences, the name of the table is the
  3917. sequence name. The table has one column, &quot;id&quot; which should be of type
  3918. integer, or if you need something larger - numeric(16). </p>
  3919. <p>For ODBC and databases that do not support sequences natively (eg mssql,
  3920. mysql), we create a table for each sequence. If the sequence has not been
  3921. defined earlier, it is created with the starting value set in $startID.</p>
  3922. <p>Note that the mssql driver's GenID() before 1.90 used to generate 16 byte
  3923. GUID's.</p>
  3924. <p><b>UpdateBlob<a name=updateblob></a>($table,$column,$val,$where)</b></p>
  3925. <p class=MsoNormal>Allows you to store a blob (in $val) into $table into
  3926. $column in a row at $where. </p>
  3927. <p>Usage: </p>
  3928. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3929. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3930. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># for oracle<br>
  3931. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, empty_blob())');<br>
  3932. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');<br>
  3933. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  3934. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># non oracle databases<br>
  3935. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');<br>
  3936. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');</pre></div>
  3937. <p>Returns true if succesful, false otherwise. Supported by MySQL, PostgreSQL,
  3938. Oci8, Oci8po and Interbase drivers. Other drivers might work, depending on the
  3939. state of development.</p>
  3940. <p>Note that when an Interbase blob is retrieved using SELECT, it still needs
  3941. to be decoded using $connection-&gt;DecodeBlob($blob); to derive the original
  3942. value in versions of PHP before 4.1.0. </p>
  3943. <p>For PostgreSQL, you can store your blob using blob oid's or as a bytea field.
  3944. You can use bytea fields but not blob oid's currently with UpdateBlob( ).
  3945. Conversely UpdateBlobFile( ) supports oid's, but not bytea data.<br>
  3946. <br>
  3947. If you do not pass in an oid, then UpdateBlob() assumes that you are storing in
  3948. bytea fields. </p>
  3949. <p>If you do not have any blob fields, you can improve you can improve general
  3950. SQL query performance by disabling blob handling with
  3951. $connection-&gt;disableBlobs = true. </p>
  3952. <p><b>UpdateClob<a name=updateclob></a>($table,$column,$val,$where)</b></p>
  3953. <p class=MsoNormal>Allows you to store a clob (in $val) into $table into
  3954. $column in a row at $where. Similar to UpdateBlob (see above), but for
  3955. Character Large OBjects. </p>
  3956. <p>Usage: </p>
  3957. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3958. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  3959. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># for oracle<br>
  3960. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, empty_clob())');<br>
  3961. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');<br>
  3962. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  3963. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># non oracle databases<br>
  3964. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');<br>
  3965. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');</pre></div>
  3966. <p><b>UpdateBlobFile<a name=updateblobfile></a>($table,$column,$path,$where,$blobtype='BLOB')</b></p>
  3967. <p>Similar to UpdateBlob, except that we pass in a file path to where the blob
  3968. resides. </p>
  3969. <p>For PostgreSQL, if you are using blob oid's, use this interface. This
  3970. interface does not support bytea fields. </p>
  3971. <p>Returns true if successful, false otherwise. </p>
  3972. <p><b>BlobEncode<a name=blobencode id=blobencode></a>($blob)</b> </p>
  3973. <p>Some databases require blob's to be encoded manually before upload. Note if
  3974. you use UpdateBlob( ) or UpdateBlobFile( ) the conversion is done automatically
  3975. for you and you do not have to call this function. For PostgreSQL, currently,
  3976. BlobEncode() can only be used for bytea fields. </p>
  3977. <p>Returns the encoded blob value. </p>
  3978. <p>Note that there is a connection property called <em>blobEncodeType</em>
  3979. which has 3 legal values: </p>
  3980. <p>false - no need to perform encoding or decoding.<br>
  3981. 'I' - blob encoding required, and returned encoded blob is a numeric value (no
  3982. need to quote).<br>
  3983. 'C' - blob encoding required, and returned encoded blob is a character value
  3984. (requires quoting). </p>
  3985. <p>This is purely for documentation purposes, so that programs that accept
  3986. multiple database drivers know what is the right thing to do when processing
  3987. blobs. </p>
  3988. <p><strong>BlobDecode<a name=blobdecode></a>($blob, $maxblobsize = false)</strong>
  3989. </p>
  3990. <p>Some databases require blob's to be decoded manually after doing a select
  3991. statement. If the database does not require decoding, then this function will
  3992. return the blob unchanged. Currently BlobDecode is only required for one
  3993. database, PostgreSQL, and only if you are using blob oid's (if you are using
  3994. bytea fields, we auto-decode for you). The default maxblobsize is set in
  3995. $connection-&gt;maxblobsize, which is set to 256K in adodb 4.54. </p>
  3996. <p>In ADOdb 4.54 and later, the blob is the return value. In earlier versions,
  3997. the blob data is sent to stdout.</p>
  3998. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  3999. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4000. style='background:#EEEEEE'>$rs = $db-&gt;Execute(&quot;select bloboid from postgres_table where id=$key&quot;);<br>
  4001. $blob = $db-&gt;BlobDecode( reset($rs-&gt;fields) );</pre></div>
  4002. <p><b>Replace<a name=replace></a>($table, $arrFields,
  4003. $keyCols,$autoQuote=false)</b></p>
  4004. <p>Try to update a record, and if the record is not found, an insert statement
  4005. is generated and executed. Returns 0 on failure, 1 if update statement worked,
  4006. 2 if no record was found and the insert was executed successfully. This differs
  4007. from MySQL's replace which deletes the record and inserts a new record. This
  4008. also means you cannot update the primary key. The only exception to this is
  4009. Interbase and its derivitives, which uses delete and insert because of some
  4010. Interbase API limitations. </p>
  4011. <p>The parameters are $table which is the table name, the $arrFields which is
  4012. an associative array where the keys are the field names, and $keyCols is the
  4013. name of the primary key, or an array of field names if it is a compound key. If
  4014. $autoQuote is set to true, then Replace() will quote all values that are
  4015. non-numeric; auto-quoting will not quote nulls. Note that auto-quoting will not
  4016. work if you use SQL functions or operators. </p>
  4017. <p>Examples: </p>
  4018. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4019. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4020. style='background:#EEEEEE'># single field primary key<br>
  4021. $ret = $db-&gt;Replace('atable', <br>
  4022. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('id'=&gt;1000,'firstname'=&gt;'Harun','lastname'=&gt;'Al-Rashid'),<br>
  4023. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'id',$autoquote = true);<span
  4024. style='mso-tab-count:1'>&nbsp; </span><br>
  4025. # generates UPDATE atable SET firstname='Harun',lastname='Al-Rashid' WHERE id=1000<br>
  4026. # or INSERT INTO atable (id,firstname,lastname) VALUES (1000,'Harun','Al-Rashid')<br>
  4027. <br>
  4028. # compound key<br>
  4029. $ret = $db-&gt;Replace('atable2', <br>
  4030. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('firstname'=&gt;'Harun','lastname'=&gt;'Al-Rashid', 'age' =&gt; 33, 'birthday' =&gt; 'null'),<br>
  4031. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('lastname','firstname'),<br>
  4032. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$autoquote = true);<br>
  4033. <br>
  4034. # no auto-quoting<br>
  4035. $ret = $db-&gt;Replace('atable2', <br>
  4036. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('firstname'=&gt;&quot;'Harun'&quot;,'lastname'=&gt;&quot;'Al-Rashid'&quot;, 'age' =&gt; 'null'),<br>
  4037. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array('lastname','firstname'));<span
  4038. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp; </span></pre></div>
  4039. <p><b>AutoExecute<a name=autoexecute></a>($table, $arrFields, $mode,
  4040. $where=false, $forceUpdate=true,$magicq=false)</b></p>
  4041. <p>Since ADOdb 4.56, you can automatically generate and execute INSERTs and
  4042. UPDATEs on a given table with this function, which is a wrapper for
  4043. GetInsertSQL() and GetUpdateSQL(). </p>
  4044. <p>AutoExecute() inserts or updates $table given an array of $arrFields, where
  4045. the keys are the field names and the array values are the field values to
  4046. store. Note that there is some overhead because the table is first queried to
  4047. extract key information before the SQL is generated. We generate an INSERT or
  4048. UPDATE based on $mode (see below). </p>
  4049. <p>Legal values for $mode are </p>
  4050. <ul type=disc>
  4051. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4052. mso-list:l5 level1 lfo9;tab-stops:list 36.0pt'>'INSERT' or 1 or DB_AUTOQUERY_INSERT
  4053. </li>
  4054. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4055. mso-list:l5 level1 lfo9;tab-stops:list 36.0pt'>'UPDATE' or 2 or
  4056. DB_AUTOQUERY_UPDATE </li>
  4057. </ul>
  4058. <p>The $where clause is required if $mode == 'UPDATE'. If $forceUpdate=false
  4059. then we will query the database first and check if the field value returned by
  4060. the query matches the current field value; only if they differ do we update
  4061. that field. </p>
  4062. <p>Returns true on success, false on error. </p>
  4063. <p>An example of its use is: </p>
  4064. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4065. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre>$record[&quot;firstName&quot;] = &quot;Carol&quot;;</pre><pre>$record[&quot;lasTname&quot;] = &quot;Smith&quot;; </pre><pre>$conn-&gt;AutoExecute($table,$record,'INSERT');</pre><pre># executes <i>&quot;INSERT INTO $table (firstName,lasTname) values ('Carol',Smith')&quot;</i>;</pre><pre><o:p>&nbsp;</o:p></pre><pre>$record[&quot;firstName&quot;] = &quot;Carol&quot;;</pre><pre>$record[&quot;lasTname&quot;] = &quot;Jones&quot;; </pre><pre>$conn-&gt;AutoExecute($table,$record,'UPDATE', &quot;lastname like 'Sm%'&quot;);</pre><pre># executes <i>&quot;UPDATE $table SET firstName='Carol',lasTname='Jones' WHERE lastname like 'Sm%'&quot;</i>;</pre></div>
  4066. <p>Note: One of the strengths of ADOdb's AutoExecute() is that only valid field
  4067. names for $table are updated. If $arrFields contains keys that are invalid
  4068. field names for $table, they are ignored. There is some overhead in doing this
  4069. as we have to query the database to get the field names, but given that you are
  4070. not directly coding the SQL yourself, you probably aren't interested in speed
  4071. at all, but convenience. </p>
  4072. <p>Since 4.62, the table name to be used can be overridden by setting
  4073. $rs-&gt;tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
  4074. called. </p>
  4075. <p>Since 4.94, setting the global variable $ADODB_QUOTE_FIELDNAMES to true will
  4076. force field names to be auto-quoted in AutoExecute(), GetInsertSQL() and
  4077. GetUpdateSQL(). </p>
  4078. <p><b>GetUpdateSQL<a name=getupdatesql></a>(&amp;$rs, $arrFields,
  4079. $forceUpdate=false,$magicq=false, $force=null)</b></p>
  4080. <p>Generate SQL to update a table given a recordset $rs, and the modified
  4081. fields of the array $arrFields (which must be an associative array holding the
  4082. column names and the new values) are compared with the current recordset. If
  4083. $forceUpdate is true, then we also generate the SQL even if $arrFields is
  4084. identical to $rs-&gt;fields. Requires the recordset to be associative. $magicq
  4085. is used to indicate whether magic quotes are enabled (see qstr()). The field
  4086. names in the array are case-insensitive.</p>
  4087. <p>Since 4.52, we allow you to pass the $force type parameter, and this
  4088. overrides the <a href="#ADODB_FORCE_TYPE">$ADODB_FORCE_TYPE</a> global
  4089. variable. </p>
  4090. <p>Since 4.62, the table name to be used can be overridden by setting
  4091. $rs-&gt;tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
  4092. called. </p>
  4093. <p><b>GetInsertSQL<a name=getinsertsql></a>(&amp;$rs, $arrFields,$magicq=false,$force_type=false)</b></p>
  4094. <p>Generate SQL to insert into a table given a recordset $rs. Requires the
  4095. query to be associative. $magicq is used to indicate whether magic quotes are
  4096. enabled (for qstr()). The field names in the array are case-insensitive.</p>
  4097. <p>Since 2.42, you can pass a table name instead of a recordset into
  4098. GetInsertSQL (in $rs), and it will generate an insert statement for that table.
  4099. </p>
  4100. <p>Since 4.52, we allow you to pass the $force_type parameter, and this
  4101. overrides the <a href="#ADODB_FORCE_TYPE">$ADODB_FORCE_TYPE</a> global
  4102. variable. </p>
  4103. <p>Since 4.62, the table name to be used can be overridden by setting
  4104. $rs-&gt;tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
  4105. called. </p>
  4106. <p><b>PageExecute<a name=pageexecute></a>($sql, $nrows, $page, $inputarr=false)</b>
  4107. </p>
  4108. <p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
  4109. 8</a>.</p>
  4110. <p><b>CachePageExecute<a name=cachepageexecute></a>($secs2cache, $sql, $nrows,
  4111. $page, $inputarr=false)</b> </p>
  4112. <p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
  4113. 8</a>. Caching version of PageExecute.</p>
  4114. <p><b>Close<a name=close></a>( )</b></p>
  4115. <p>Close the database connection. PHP4 proudly states that we no longer have to
  4116. clean up at the end of the connection because the reference counting mechanism
  4117. of PHP4 will automatically clean up for us.</p>
  4118. <p><b>StartTrans<a name=starttrans></a>( )</b></p>
  4119. <p>Start a monitored transaction. As SQL statements are executed, ADOdb will
  4120. monitor for SQL errors, and if any are detected, when CompleteTrans() is
  4121. called, we auto-rollback. </p>
  4122. <p>To understand why StartTrans() is superior to BeginTrans(), let us examine a
  4123. few ways of using BeginTrans(). The following is the wrong way to use
  4124. transactions: </p>
  4125. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4126. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4127. style='background:#EEEEEE'>$DB-&gt;BeginTrans();<br>
  4128. $DB-&gt;Execute(&quot;update table1 set val=$val1 where id=$id&quot;);<br>
  4129. $DB-&gt;Execute(&quot;update table2 set val=$val2 where id=$id&quot;);<br>
  4130. $DB-&gt;CommitTrans();</pre></div>
  4131. <p>because you perform no error checking. It is possible to update table1 and
  4132. for the update on table2 to fail. Here is a better way: </p>
  4133. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4134. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4135. style='background:#EEEEEE'>$DB-&gt;BeginTrans();<br>
  4136. $ok = $DB-&gt;Execute(&quot;update table1 set val=$val1 where id=$id&quot;);<br>
  4137. if ($ok) $ok = $DB-&gt;Execute(&quot;update table2 set val=$val2 where id=$id&quot;);<br>
  4138. if ($ok) $DB-&gt;CommitTrans();<br>
  4139. else $DB-&gt;RollbackTrans();</pre></div>
  4140. <p>Another way is (since ADOdb 2.0): </p>
  4141. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4142. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4143. style='background:#EEEEEE'>$DB-&gt;BeginTrans();<br>
  4144. $ok = $DB-&gt;Execute(&quot;update table1 set val=$val1 where id=$id&quot;);<br>
  4145. if ($ok) $ok = $DB-&gt;Execute(&quot;update table2 set val=$val2 where id=$id&quot;);<br>
  4146. $DB-&gt;CommitTrans($ok);</pre></div>
  4147. <p>Now it is a headache monitoring $ok all over the place. StartTrans() is an
  4148. improvement because it monitors all SQL errors for you. This is particularly
  4149. useful if you are calling black-box functions in which SQL queries might be
  4150. executed. Also all BeginTrans, CommitTrans and RollbackTrans calls inside a
  4151. StartTrans block will be disabled, so even if the black box function does a
  4152. commit, it will be ignored. </p>
  4153. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4154. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4155. style='background:#EEEEEE'>$DB-&gt;StartTrans();<br>
  4156. CallBlackBox();<br>
  4157. $DB-&gt;Execute(&quot;update table1 set val=$val1 where id=$id&quot;);<br>
  4158. $DB-&gt;Execute(&quot;update table2 set val=$val2 where id=$id&quot;);<br>
  4159. $DB-&gt;CompleteTrans();</pre></div>
  4160. <p>Note that a StartTrans blocks are nestable, the inner blocks are ignored. </p>
  4161. <p><b>CompleteTrans<a name=completetrans></a>($autoComplete=true)</b></p>
  4162. <p>Complete a transaction called with StartTrans(). This function monitors for
  4163. SQL errors, and will commit if no errors have occured, otherwise it will
  4164. rollback. Returns true on commit, false on rollback. If the parameter
  4165. $autoComplete is true monitor sql errors and commit and rollback as
  4166. appropriate. Set $autoComplete to false to force rollback even if no SQL error
  4167. detected. </p>
  4168. <p><b>FailTrans<a name=failtrans></a>( )</b></p>
  4169. <p>Fail a transaction started with StartTrans(). The rollback will only occur
  4170. when CompleteTrans() is called. </p>
  4171. <p><b>HasFailedTrans<a name=hasfailedtrans></a>( )</b></p>
  4172. <p>Check whether smart transaction has failed, eg. returns true if there was an
  4173. error in SQL execution or FailTrans() was called. If not within smart
  4174. transaction, returns false. </p>
  4175. <p><b>BeginTrans<a name=begintrans></a>( )</b></p>
  4176. <p>Begin a transaction. Turns off autoCommit. Returns true if successful. Some
  4177. databases will always return false if transaction support is not available. Any
  4178. open transactions will be rolled back when the connection is closed. Among the
  4179. databases that support transactions are Oracle, PostgreSQL, Interbase, MSSQL,
  4180. certain versions of MySQL, DB2, Informix, Sybase, etc.</p>
  4181. <p>Note that <a href="#starttrans">StartTrans()</a> and CompleteTrans() is a
  4182. superior method of handling transactions, available since ADOdb 3.40. For a
  4183. explanation, see the <a href="#starttrans">StartTrans()</a> documentation. </p>
  4184. <p>You can also use the ADOdb <a href="#errorhandling">error handler</a> to die
  4185. and rollback your transactions for you transparently. Some buggy database
  4186. extensions are known to commit all outstanding tranasactions, so you might want
  4187. to explicitly do a $DB-&gt;RollbackTrans() in your error handler for safety. </p>
  4188. <h4>Detecting Transactions</h4>
  4189. <p>Since ADOdb 2.50, you are able to detect when you are inside a transaction.
  4190. Check that $connection-&gt;transCnt &gt; 0. This variable is incremented whenever
  4191. BeginTrans() is called, and decremented whenever RollbackTrans() or
  4192. CommitTrans() is called. </p>
  4193. <p><b>CommitTrans<a name=committrans></a>($ok=true)</b></p>
  4194. <p>End a transaction successfully. Returns true if successful. If the database
  4195. does not support transactions, will return true also as data is always
  4196. committed. </p>
  4197. <p>If you pass the parameter $ok=false, the data is rolled back. See example in
  4198. BeginTrans().</p>
  4199. <p><b>RollbackTrans<a name=rollbacktrans></a>( )</b></p>
  4200. <p>End a transaction, rollback all changes. Returns true if successful. If the
  4201. database does not support transactions, will return false as data is never
  4202. rollbacked. </p>
  4203. <p><b>SetTransactionMode<a name=SetTransactionMode></a>($mode )</b></p>
  4204. <p>SetTransactionMode allows you to pass in the transaction mode to use for all
  4205. subsequent transactions. Note: if you have persistent connections and using
  4206. mssql or mysql, you might have to explicitly reset your transaction mode at the
  4207. beginning of each page request. This is only supported in postgresql, mssql,
  4208. mysql with InnoDB and oci8 currently. For example: </p>
  4209. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4210. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre>$db-&gt;SetTransactionMode(&quot;SERIALIZABLE&quot;);</pre><pre>$db-&gt;BeginTrans();</pre><pre>$db-&gt;Execute(...); $db-&gt;Execute(...);</pre><pre>$db-&gt;CommitTrans();</pre><pre><o:p>&nbsp;</o:p></pre><pre>$db-&gt;SetTransactionMode(&quot;&quot;); // restore to default</pre><pre>$db-&gt;StartTrans();</pre><pre>$db-&gt;Execute(...); $db-&gt;Execute(...);</pre><pre>$db-&gt;CompleteTrans();</pre></div>
  4211. <p>Supported values to pass in: </p>
  4212. <ul type=disc>
  4213. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4214. mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>READ UNCOMMITTED (allows
  4215. dirty reads, but fastest) </li>
  4216. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4217. mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>READ COMMITTED (default
  4218. postgres, mssql and oci8) </li>
  4219. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4220. mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>REPEATABLE READ (default
  4221. mysql) </li>
  4222. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  4223. mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>SERIALIZABLE (slowest and
  4224. most restrictive) </li>
  4225. </ul>
  4226. <p>You can also pass in database specific values such as 'SNAPSHOT' for mssql
  4227. or 'READ ONLY' for oci8/postgres. </p>
  4228. <p>See transaction levels for <a
  4229. href="http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html">PostgreSQL</a>,
  4230. <a
  4231. href="http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm">Oracle</a>,
  4232. <a href="http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html">MySQL</a>,
  4233. and <a href="http://msdn.microsoft.com/en-us/ms173763.aspx">MS SQL Server</a>.
  4234. </p>
  4235. <p><b>GetAssoc<a name=getassoc1></a>($sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
  4236. <p>Returns an associative array for the given query $sql with optional bind
  4237. parameters in $inputarr. If the number of columns returned is greater to two, a
  4238. 2-dimensional array is returned, with the first column of the recordset becomes
  4239. the keys to the rest of the rows. If the columns is equal to two, a 1-dimensional
  4240. array is created, where the the keys directly map to the values (unless
  4241. $force_array is set to true, when an array is created for each value). </p>
  4242. <p>Examples:<a name=getassocex></a></p>
  4243. <p>We have the following data in a recordset:</p>
  4244. <p>row1: Apple, Fruit, Edible<br>
  4245. row2: Cactus, Plant, Inedible<br>
  4246. row3: Rose, Flower, Edible</p>
  4247. <p>GetAssoc will generate the following 2-dimensional associative array:</p>
  4248. <p>Apple =&gt; array[Fruit, Edible]<br>
  4249. Cactus =&gt; array[Plant, Inedible]<br>
  4250. Rose =&gt; array[Flower,Edible]</p>
  4251. <p>If the dataset is:</p>
  4252. <p>row1: Apple, Fruit<br>
  4253. row2: Cactus, Plant<br>
  4254. row3: Rose, Flower </p>
  4255. <p>GetAssoc will generate the following 1-dimensional associative array (with
  4256. $force_array==false):</p>
  4257. <p>Apple =&gt; Fruit<br>
  4258. Cactus=&gt;Plant<br>
  4259. Rose=&gt;Flower </p>
  4260. <p>The function returns:</p>
  4261. <p>The associative array, or false if an error occurs.</p>
  4262. <p><b>CacheGetAssoc<a name=cachegetassoc></a>([$secs2cache,] $sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
  4263. <p>Caching version of <a href="#getassoc1">GetAssoc</a> function above. </p>
  4264. <p><b>GetMedian<a name=getmedian></a>($table, $field, $where='')</b></p>
  4265. <p>Returns the median value of $field for $table. The $where clause is
  4266. optional. If used, make sure the WHERE is included, as in &quot;WHERE name &gt;
  4267. 'A'&quot;. If an error occurs, false is returned. Since ADOdb 5.06 and PHP
  4268. 4.991. </p>
  4269. <p><b>GetOne<a name=getone></a>($sql,$inputarr=false)</b></p>
  4270. <p>Executes the SQL and returns the first field of the first row. The recordset
  4271. and remaining rows are discarded for you automatically. If an error occur,
  4272. false is returned; use ErrorNo() or ErrorMsg() to get the error details. Since
  4273. 4.96/5.00, we return null if no records were found. And since 4.991/5.06, you
  4274. can have change the return value if no records are found using the global
  4275. variable $ADODB_GETONE_EOF: $ADODB_GETONE_EOF = false;</p>
  4276. <p><b>GetRow<a name=getrow></a>($sql,$inputarr=false)</b></p>
  4277. <p>Executes the SQL and returns the first row as an array. The recordset and
  4278. remaining rows are discarded for you automatically. If no records are returned,
  4279. an empty array is returned. If an error occurs, false is returned.</p>
  4280. <p><b>GetAll<a name=getall></a>($sql,$inputarr=false)</b></p>
  4281. <p>Executes the SQL and returns the all the rows as a 2-dimensional array. The
  4282. recordset is discarded for you automatically. If an error occurs, false is
  4283. returned. <i>GetArray</i> is a synonym for <i>GetAll</i>.</p>
  4284. <p><b>GetCol<a name=getcol></a>($sql,$inputarr=false,$trim=false)</b></p>
  4285. <p>Executes the SQL and returns all elements of the first column as a
  4286. 1-dimensional array. The recordset is discarded for you automatically. If an
  4287. error occurs, false is returned.</p>
  4288. <p><b>CacheGetOne<a name=cachegetone></a>([$secs2cache,] $sql,$inputarr=false),
  4289. CacheGetRow<a name=cachegetrow></a>([$secs2cache,] $sql,$inputarr=false),
  4290. CacheGetAll<a name=cachegetall></a>([$secs2cache,] $sql,$inputarr=false),
  4291. CacheGetCol<a name=cachegetcol></a>([$secs2cache,]
  4292. $sql,$inputarr=false,$trim=false)</b></p>
  4293. <p>Similar to above Get* functions, except that the recordset is serialized and
  4294. cached in the $ADODB_CACHE_DIR directory for $secs2cache seconds. Good for
  4295. speeding up queries on rarely changing data. Note that the $secs2cache
  4296. parameter is optional. If omitted, we use the value in
  4297. $connection-&gt;cacheSecs (default is 3600 seconds, or 1 hour). </p>
  4298. <p><b>Prepare<a name=prepare></a>($sql )</b></p>
  4299. <p>Prepares (compiles) an SQL query for repeated execution. Bind parameters are
  4300. denoted by ?, except for the oci8 driver, which uses the traditional Oracle
  4301. :varname convention. </p>
  4302. <p>Returns an array containing the original sql statement in the first array
  4303. element; the remaining elements of the array are driver dependent. If there is
  4304. an error, or we are emulating Prepare( ), we return the original $sql string.
  4305. This is because all error-handling has been centralized in Execute( ).</p>
  4306. <p>Prepare( ) cannot be used with functions that use SQL query rewriting
  4307. techniques, e.g. PageExecute( ) and SelectLimit( ).</p>
  4308. <p>Example:</p>
  4309. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4310. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4311. style='background:#EEEEEE'>$stmt = $DB-&gt;Prepare('insert into table (col1,col2) values (?,?)');<br>
  4312. for ($i=0; $i &lt; $max; $i++)<br>
  4313. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;Execute($stmt,array((string) rand(), $i));</pre></div>
  4314. <p>Also see InParameter(), OutParameter() and PrepareSP() below. Only supported
  4315. internally by interbase, oci8 and selected ODBC-based drivers, otherwise it is
  4316. emulated. There is no performance advantage to using Prepare() with emulation. </p>
  4317. <p>Important: Due to limitations or bugs in PHP, if you are getting errors when
  4318. you using prepared queries, try setting $ADODB_COUNTRECS = false before
  4319. preparing. This behaviour has been observed with ODBC. </p>
  4320. <p><b>IfNull<a name=ifnull></a>($field, $nullReplacementValue)</b></p>
  4321. <p>Portable IFNULL function (NVL in Oracle). Returns a string that represents
  4322. the function that checks whether a $field is null for the given database, and
  4323. if null, change the value returned to $nullReplacementValue. Eg.</p>
  4324. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4325. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4326. style='background:#EEEEEE'>$sql = <span style='color:#993300'>'SELECT '</span>.$db-&gt;IfNull('name', <span
  4327. style='color:#993300'>&quot;'- unknown -'&quot;</span>).<span style='color:
  4328. #993300'> ' FROM table'</span>;</pre></div>
  4329. <p><b>length</b><a name=length></a></p>
  4330. <p>This is not a function, but a property. Some databases have
  4331. &quot;length&quot; and others &quot;len&quot; as the function to measure the
  4332. length of a string. To use this property: </p>
  4333. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4334. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4335. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span>$sql = <span
  4336. style='color:#993300'>&quot;SELECT &quot;</span>.$db-&gt;length.<span
  4337. style='color:#993300'>&quot;(field) from table&quot;</span>;<br>
  4338. <span style='mso-spacerun:yes'>&nbsp; </span>$rs = $db-&gt;Execute($sql);</pre></div>
  4339. <p><b>random</b><a name=random></a></p>
  4340. <p>This is not a function, but a property. This is a string that holds the sql
  4341. to generate a random number between 0.0 and 1.0 inclusive. </p>
  4342. <p><b>substr</b><a name=substr></a></p>
  4343. <p>This is not a function, but a property. Some databases have
  4344. &quot;substr&quot; and others &quot;substring&quot; as the function to retrieve
  4345. a sub-string. To use this property: </p>
  4346. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4347. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4348. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span>$sql = <span
  4349. style='color:#993300'>&quot;SELECT &quot;</span>.$db-&gt;substr.<span
  4350. style='color:#993300'>&quot;(field, $offset, $length) from table&quot;</span>;<br>
  4351. <span style='mso-spacerun:yes'>&nbsp; </span>$rs = $db-&gt;Execute($sql);</pre></div>
  4352. <p>For all databases, the 1st parameter of <i>substr</i> is the field, the 2nd
  4353. is the offset (1-based) to the beginning of the sub-string, and the 3rd is the
  4354. length of the sub-string. </p>
  4355. <p><b>Param<a name=param></a>($name)</b></p>
  4356. <p>Generates a bind placeholder portably. For most databases, the bind
  4357. placeholder is &quot;?&quot;. However some databases use named bind parameters
  4358. such as Oracle, eg &quot;:somevar&quot;. This allows us to portably define an
  4359. SQL statement with bind parameters: </p>
  4360. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4361. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4362. style='background:#EEEEEE'>$sql = <span style='color:#993300'>'insert into table (col1,col2) values ('</span>.$DB-&gt;Param('a').<span
  4363. style='color:#993300'>','</span>.$DB-&gt;Param('b').<span style='color:#993300'>')'</span>;<br>
  4364. <span style='color:#006600'># generates 'insert into table (col1,col2) values (?,?)'<br>
  4365. # or<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'insert into table (col1,col2) values (:a,:b)</span>'<br>
  4366. $stmt = $DB-&gt;Prepare($sql);<br>
  4367. $stmt = $DB-&gt;Execute($stmt,array('one','two'));</pre></div>
  4368. <p><b>PrepareSP<a name=preparesp></a>($sql, $cursor=false )</b></p>
  4369. <p>When calling stored procedures in mssql and oci8 (oracle), and you might
  4370. want to directly bind to parameters that return values, or for special LOB
  4371. handling. PrepareSP() allows you to do so. </p>
  4372. <p>Returns the same array or $sql string as Prepare( ) above. If you do not
  4373. need to bind to return values, you should use Prepare( ) instead.</p>
  4374. <p>The 2nd parameter, $cursor is not used except with oci8. Setting it to true
  4375. will force OCINewCursor to be called; this is to support output REF CURSORs. </p>
  4376. <p>For examples of usage of PrepareSP( ), see InParameter( ) below. </p>
  4377. <p>Note: in the mssql driver, preparing stored procedures requires a special
  4378. function call, mssql_init( ), which is called by this function. PrepareSP( ) is
  4379. available in all other drivers, and is emulated by calling Prepare( ). </p>
  4380. <p><b>InParameter<a name=inparameter></a>($stmt, $var, $name, $maxLen = 4000,
  4381. $type = false )</b></p>
  4382. <p class=MsoNormal>Binds a PHP variable as input to a stored procedure
  4383. variable. The parameter <i>$stmt</i> is the value returned by PrepareSP(), <i>$var</i>
  4384. is the PHP variable you want to bind, $name is the name of the stored procedure
  4385. variable. Optional is <i>$maxLen</i>, the maximum length of the data to bind,
  4386. and $type which is database dependant. Consult <a
  4387. href="http://php.net/mssql_bind">mssql_bind</a> and <a
  4388. href="http://php.net/ocibindbyname">ocibindbyname</a> docs at php.net for more
  4389. info on legal values for $type. </p>
  4390. <p>InParameter() is a wrapper function that calls Parameter() with
  4391. $isOutput=false. The advantage of this function is that it is self-documenting,
  4392. because the $isOutput parameter is no longer needed. Only for mssql and oci8
  4393. currently. </p>
  4394. <p>Here is an example using oci8: </p>
  4395. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4396. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  4397. style='color:green'># For oracle, Prepare and PrepareSP are identical</span></pre><pre>$stmt = $db-&gt;PrepareSP(</pre><pre
  4398. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
  4399. style='color:#993300'>&quot;declare RETVAL integer; <br>
  4400. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>begin<br>
  4401. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>:RETVAL := SP_RUNSOMETHING(:myid,:group);<br>
  4402. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>end;&quot;</span>);<br>
  4403. $db-&gt;InParameter($stmt,$id,'myid');<br>
  4404. $db-&gt;InParameter($stmt,$group,'group',64);<br>
  4405. $db-&gt;OutParameter($stmt,$ret,'RETVAL');<br>
  4406. $db-&gt;Execute($stmt);</pre></div>
  4407. <p>The same example using mssql:</p>
  4408. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4409. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  4410. style='color:green'># @RETVAL = SP_RUNSOMETHING @myid,@group</span></pre><pre>$stmt = $db-&gt;PrepareSP(<span
  4411. style='color:#993333'>'</span><span style='color:#993300'>SP_RUNSOMETHING</span><span
  4412. style='color:#993333'>'</span>); <br>
  4413. <span style='color:green'># note that the parameter name does not have @ in front!</span></pre><pre>$db-&gt;InParameter($stmt,$id,'myid');</pre><pre>$db-&gt;InParameter($stmt,$group,'group',64);</pre><pre
  4414. style='background:#EEEEEE'><span style='color:green'># return value in mssql - RETVAL is hard-coded name</span> <br>
  4415. $db-&gt;OutParameter($stmt,$ret,'RETVAL');<br>
  4416. $db-&gt;Execute($stmt); </pre></div>
  4417. <p>Note that the only difference between the oci8 and mssql implementations is
  4418. $sql.</p>
  4419. <p>If $type parameter is set to false, in mssql, $type will be dynamicly
  4420. determined based on the type of the PHP variable passed <span style='font-family:
  4421. "Courier New"'>(string =&gt; SQLCHAR, boolean =&gt;SQLINT1, integer
  4422. =&gt;SQLINT4 or float/double=&gt;SQLFLT8)</span>. </p>
  4423. <p>In oci8, $type can be set to OCI_B_FILE (Binary-File), OCI_B_CFILE
  4424. (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and
  4425. OCI_B_ROWID (ROWID). To pass in a null, use<span style='font-family:"Courier New"'>
  4426. $db-&gt;Parameter($stmt, $null=null, 'param')</span>. </p>
  4427. <p><b>OutParameter<a name=outparameter></a>($stmt, $var, $name, $maxLen = 4000,
  4428. $type = false )</b></p>
  4429. <p class=MsoNormal>Binds a PHP variable as output from a stored procedure
  4430. variable. The parameter <i>$stmt</i> is the value returned by PrepareSP(), <i>$var</i>
  4431. is the PHP variable you want to bind, <i>$name</i> is the name of the stored
  4432. procedure variable. Optional is <i>$maxLen</i>, the maximum length of the data
  4433. to bind, and <i>$type</i> which is database dependant. </p>
  4434. <p>OutParameter() is a wrapper function that calls Parameter() with
  4435. $isOutput=true. The advantage of this function is that it is self-documenting,
  4436. because the $isOutput parameter is no longer needed. Only for mssql and oci8
  4437. currently. </p>
  4438. <p>For an example, see <a href="#inparameter">InParameter</a>. </p>
  4439. <p><b>Parameter<a name=parameter></a>($stmt, $var, $name, $isOutput=false,
  4440. $maxLen = 4000, $type = false )</b></p>
  4441. <p>Note: This function is deprecated, because of the new InParameter() and
  4442. OutParameter() functions. These are superior because they are self-documenting,
  4443. unlike Parameter(). </p>
  4444. <p>Adds a bind parameter suitable for return values or special data handling
  4445. (eg. LOBs) after a statement has been prepared using PrepareSP(). Only for
  4446. mssql and oci8 currently. The parameters are:<br>
  4447. <br>
  4448. $<b><i>stmt</i></b> Statement returned by Prepare() or PrepareSP().<br>
  4449. $<b><i>var</i></b> PHP variable to bind to. Make sure you pre-initialize it!<br>
  4450. $<b><i>name</i></b> Name of stored procedure variable name to bind to.<br>
  4451. [$<b><i>isOutput</i></b>] Indicates direction of parameter 0/false=IN 1=OUT 2=
  4452. IN/OUT. This is ignored in oci8 as this driver auto-detects the direction.<br>
  4453. [$<b>maxLen</b>] Maximum length of the parameter variable.<br>
  4454. [$<b>type</b>] Consult <a href="http://php.net/mssql_bind">mssql_bind</a> and <a
  4455. href="http://php.net/ocibindbyname">ocibindbyname</a> docs at php.net for more
  4456. info on legal values for type.</p>
  4457. <p>Lastly, in oci8, bind parameters can be reused without calling PrepareSP( ) or
  4458. Parameters again. This is not possible with mssql. An oci8 example:</p>
  4459. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4460. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>$id = 0; $i = 0;<br>
  4461. $stmt = $db-&gt;PrepareSP( <span style='color:#993300'>&quot;update table set val=:i where id=:id&quot;</span>);<br>
  4462. $db-&gt;Parameter($stmt,$id,'id');<br>
  4463. $db-&gt;Parameter($stmt,$i, 'i');<br>
  4464. for ($cnt=0; $cnt &lt; 1000; $cnt++) {<br>
  4465. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$id = $cnt; <br>
  4466. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$i = $cnt * $cnt; <span
  4467. style='color:green'># works with oci8!</span></pre><pre style='background:#EEEEEE'><span
  4468. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute($stmt); <br>
  4469. }</pre></div>
  4470. <p><b>Bind<a name=bind></a>($stmt, $var, $size=4001, $type=false, $name=false)</b></p>
  4471. <p>This is a low-level function supported only by the oci8 driver. <b>Avoid
  4472. using</b> unless you only want to support Oracle. The Parameter( ) function is
  4473. the recommended way to go with bind variables.</p>
  4474. <p>Bind( ) allows you to use bind variables in your sql statement. This binds a
  4475. PHP variable to a name defined in an Oracle sql statement that was previously
  4476. prepared using Prepare(). Oracle named variables begin with a colon, and ADOdb
  4477. requires the named variables be called :0, :1, :2, :3, etc. The first
  4478. invocation of Bind() will match :0, the second invocation will match :1, etc.
  4479. Binding can provide 100% speedups for insert, select and update statements. </p>
  4480. <p>The other variables, $size sets the buffer size for data storage, $type is
  4481. the optional descriptor type OCI_B_FILE (Binary-File), OCI_B_CFILE
  4482. (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and
  4483. OCI_B_ROWID (ROWID). Lastly, instead of using the default :0, :1, etc names,
  4484. you can define your own bind-name using $name. </p>
  4485. <p>The following example shows 3 bind variables being used: p1, p2 and p3.
  4486. These variables are bound to :0, :1 and :2.</p>
  4487. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4488. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4489. style='background:#EEEEEE'>$stmt = $DB-&gt;Prepare(&quot;insert into table (col0, col1, col2) values (:0, :1, :2)&quot;);<br>
  4490. $DB-&gt;Bind($stmt, $p1);<br>
  4491. $DB-&gt;Bind($stmt, $p2);<br>
  4492. $DB-&gt;Bind($stmt, $p3);<br>
  4493. for ($i = 0; $i &lt; $max; $i++) { <br>
  4494. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$p1 = ?; $p2 = ?; $p3 = ?;<br>
  4495. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$DB-&gt;Execute($stmt);<br>
  4496. }</pre></div>
  4497. <p>You can also use named variables:</p>
  4498. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4499. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4500. style='background:#EEEEEE'>$stmt = $DB-&gt;Prepare(&quot;insert into table (col0, col1, col2) values (:name0, :name1, :name2)&quot;);<br>
  4501. $DB-&gt;Bind($stmt, $p1, &quot;name0&quot;);<br>
  4502. $DB-&gt;Bind($stmt, $p2, &quot;name1&quot;);<br>
  4503. $DB-&gt;Bind($stmt, $p3, &quot;name2&quot;);<br>
  4504. for ($i = 0; $i &lt; $max; $i++) { <br>
  4505. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$p1 = ?; $p2 = ?; $p3 = ?;<br>
  4506. <span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>$DB-&gt;Execute($stmt);<br>
  4507. }</pre></div>
  4508. <p><b>LogSQL($enable=true)</b><a name=logsql></a></p>
  4509. <p class=MsoNormal>Call this method to install a SQL logging and timing
  4510. function (using fnExecute). Then all SQL statements are logged into an
  4511. adodb_logsql table in a database. If the adodb_logsql table does not exist,
  4512. ADOdb will create the table if you have the appropriate permissions. Returns
  4513. the previous logging value (true for enabled, false for disabled). Here are
  4514. samples of the DDL for selected databases: </p>
  4515. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4516. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  4517. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>mysql:</b></pre><pre><span
  4518. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CREATE TABLE adodb_logsql (</pre><pre><span
  4519. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>created datetime NOT NULL,</pre><pre><span
  4520. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql0 varchar(250) NOT NULL,</pre><pre><span
  4521. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql1 text NOT NULL,</pre><pre><span
  4522. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>params text NOT NULL,</pre><pre><span
  4523. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>tracer text NOT NULL,</pre><pre><span
  4524. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>timer decimal(16,6) NOT NULL</pre><pre><span
  4525. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>)</pre><pre><span
  4526. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span
  4527. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>postgres:</b></pre><pre><span
  4528. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CREATE TABLE adodb_logsql (</pre><pre><span
  4529. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>created timestamp NOT NULL,</pre><pre><span
  4530. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql0 varchar(250) NOT NULL,</pre><pre><span
  4531. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql1 text NOT NULL,</pre><pre><span
  4532. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>params text NOT NULL,</pre><pre><span
  4533. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>tracer text NOT NULL,</pre><pre><span
  4534. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>timer decimal(16,6) NOT NULL</pre><pre><span
  4535. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>)</pre><pre><span
  4536. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span
  4537. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>mssql:</b></pre><pre><span
  4538. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CREATE TABLE adodb_logsql (</pre><pre><span
  4539. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>created datetime NOT NULL,</pre><pre><span
  4540. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql0 varchar(250) NOT NULL,</pre><pre><span
  4541. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql1 varchar(4000) NOT NULL,</pre><pre><span
  4542. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>params varchar(3000) NOT NULL,</pre><pre><span
  4543. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>tracer varchar(500) NOT NULL,</pre><pre><span
  4544. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>timer decimal(16,6) NOT NULL</pre><pre><span
  4545. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>)</pre><pre><span
  4546. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span
  4547. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>oci8:</b></pre><pre><span
  4548. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CREATE TABLE adodb_logsql (</pre><pre><span
  4549. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>created date NOT NULL,</pre><pre><span
  4550. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql0 varchar(250) NOT NULL,</pre><pre><span
  4551. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>sql1 varchar(4000) NOT NULL,</pre><pre><span
  4552. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>params varchar(4000),</pre><pre><span
  4553. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>tracer varchar(4000),</pre><pre><span
  4554. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>timer decimal(16,6) NOT NULL</pre><pre><span
  4555. style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>)</pre></div>
  4556. <p class=MsoNormal>Usage: </p>
  4557. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4558. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4559. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;LogSQL(); // turn on logging<br>
  4560. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>:<br>
  4561. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;Execute(...);<br>
  4562. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp; </span>:<br>
  4563. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$conn-&gt;LogSQL(false); // turn off logging<br>
  4564. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  4565. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span># output summary of SQL logging results<br>
  4566. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$perf = NewPerfMonitor($conn);<br>
  4567. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>echo $perf-&gt;SuspiciousSQL();<br>
  4568. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>echo $perf-&gt;ExpensiveSQL();</pre></div>
  4569. <p>One limitation of logging is that rollback also prevents SQL from being
  4570. logged. </p>
  4571. <p>If you prefer to use another name for the table used to store the SQL, you
  4572. can override it by calling adodb_perf::table($tablename), where $tablename is
  4573. the new table name (you will still need to manually create the table yourself).
  4574. An example: </p>
  4575. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4576. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4577. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>include('adodb.inc.php');<br>
  4578. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>include('adodb-perf.inc.php');<br>
  4579. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>adodb_perf::table('my_logsql_table');</pre></div>
  4580. <p class=MsoNormal>Also see <a href="docs-perf.htm">Performance Monitor</a>. </p>
  4581. <p><b>fnExecute and fnCacheExecute properties</b><a name=fnexecute
  4582. id=fnexecute></a></p>
  4583. <p>These two properties allow you to define bottleneck functions for all sql
  4584. statements processed by ADOdb. This allows you to perform statistical analysis
  4585. and query-rewriting of your sql. </p>
  4586. <p><b>Examples of fnExecute</b></p>
  4587. <p>Here is an example of using fnExecute, to count all cached queries and
  4588. non-cached queries, you can do this:</p>
  4589. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4590. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
  4591. style='color:#006600'># $db is the connection object</span></pre><pre>function &amp;CountExecs($db, $sql, $inputarray)</pre><pre>{</pre><pre>global $EXECS;</pre><pre><o:p>&nbsp;</o:p></pre><pre><span
  4592. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (!is_array(inputarray)) $EXECS++;</pre><pre><span
  4593. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:#006600'># handle 2-dimensional input arrays</span></pre><pre><span
  4594. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>else if (is_array(reset($inputarray))) $EXECS += sizeof($inputarray);</pre><pre><span
  4595. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>else $EXECS++;</pre><pre><span
  4596. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre><pre><span style='mso-tab-count:
  4597. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='color:#006600'># in PHP4.4 and PHP5, we need to return a value by reference</span></pre><pre><span
  4598. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$null = null;</pre><pre><span
  4599. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>return $null;</pre><pre>}</pre><pre><o:p>&nbsp;</o:p></pre><pre><span
  4600. style='color:#006600'># $db is the connection object</span></pre><pre>function CountCachedExecs($db, $secs2cache, $sql, $inputarray)</pre><pre
  4601. style='background:#EEEEEE'>{<br>
  4602. global $CACHED; $CACHED++;<br>
  4603. }<br>
  4604. <br>
  4605. $db = NewADOConnection('mysql');<br>
  4606. $db-&gt;Connect(...);<br>
  4607. $db-&gt;<strong><span style='font-family:"Courier New"'>fnExecute</span></strong> = 'CountExecs';<br>
  4608. $db-&gt;<strong><span style='font-family:"Courier New"'>fnCacheExecute</span></strong> = 'CountCachedExecs';<br>
  4609. <span style='mso-spacerun:yes'>&nbsp;</span>:<br>
  4610. <span style='mso-spacerun:yes'>&nbsp;</span>:<br>
  4611. <span style='color:#006600'># After many sql statements:</span>`<br>
  4612. printf(&quot;&lt;p&gt;Total queries=%d; total cached=%d&lt;/p&gt;&quot;,$EXECS+$CACHED, $CACHED);</pre></div>
  4613. <p>The fnExecute function is called before the sql is parsed and executed, so
  4614. you can perform a query rewrite. If you are passing in a prepared statement,
  4615. then $sql is an array (see <a href="#prepare">Prepare</a>). The fnCacheExecute
  4616. function is only called if the recordset returned was cached. The function
  4617. parameters match the Execute and CacheExecute functions respectively, except
  4618. that $this (the connection object) is passed as the first parameter.</p>
  4619. <p>Since ADOdb 3.91, the behaviour of fnExecute varies depending on whether the
  4620. defined function returns a value. If it does not return a value, then the $sql
  4621. is executed as before. This is useful for query rewriting or counting sql
  4622. queries. </p>
  4623. <p>On the other hand, you might want to replace the Execute function with one
  4624. of your own design. If this is the case, then have your function return a
  4625. value. If a value is returned, that value is returned immediately, without any
  4626. further processing. This is used internally by ADOdb to implement LogSQL()
  4627. functionality. </p>
  4628. <div class=MsoNormal align=center style='text-align:center'>
  4629. <hr size=2 width="100%" align=center>
  4630. </div>
  4631. <h3>ADOConnection Utility Functions</h3>
  4632. <p><b>BlankRecordSet<a name=blankrecordset></a>([$queryid])</b></p>
  4633. <p>No longer available - removed since 1.99.</p>
  4634. <p><b>Concat<a name=concat></a>($s1,$s2,....)</b></p>
  4635. <p>Generates the sql string used to concatenate $s1, $s2, etc together. Uses
  4636. the string in the concat_operator field to generate the concatenation. Override
  4637. this function if a concatenation operator is not used, eg. MySQL.</p>
  4638. <p>Returns the concatenated string.</p>
  4639. <p><b>DBDate<a name=dbdate></a>($date)</b></p>
  4640. <p>Format the $<b>date</b> in the format the database accepts - the return
  4641. string is also quoted. This is used when you are sending dates to the database
  4642. (eg INSERT, UPDATE or where clause of SELECT statement). The $<b>date</b>
  4643. parameter can be a PHP DateTime object (since ADOdb 5.09), a Unix integer timestamp or an ISO format Y-m-d. Uses the
  4644. fmtDate field, which holds the format to use. If null or false or '' is passed
  4645. in, it will be converted to an SQL null.</p>
  4646. <p>Returns the date as a quoted string.</p>
  4647. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4648. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  4649. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; &quot;.$db-&gt;DBDate(&quot;$year-$month-$day&quot;);</pre><pre><span
  4650. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute($sql);</pre></div>
  4651. <p>Note to retrieve a date column in a specific format, use <a href="#sqldate">SQLDate</a>.
  4652. </p>
  4653. <p><b>BindDate<a name=binddate></a>($date)</b></p>
  4654. <p>Format the $<b>date</b> in the bind format the database accepts. Normally
  4655. this means that the date string is not quoted, unlike DBDate, which quotes the
  4656. string. </p>
  4657. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4658. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  4659. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; &quot;.$db-&gt;Param('0');</pre><pre><span
  4660. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// or</pre><pre><span style='mso-tab-count:
  4661. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; ?&quot;;</pre><pre><span
  4662. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute($sql,array($db-&gt;BindDate(&quot;$year-$month-$day&quot;));</pre></div>
  4663. <p><b>DBTimeStamp<a name=dbtimestamp></a>($ts)</b></p>
  4664. <p>Format the timestamp $<b>ts</b> in the format the database accepts; this can
  4665. be a PHP DateTime object (since ADOdb 5.09), a Unix integer timestamp or an ISO format Y-m-d H:i:s. Uses the fmtTimeStamp
  4666. field, which holds the format to use. If null or false or '' is passed in, it
  4667. will be converted to an SQL null.</p>
  4668. <p>Returns the timestamp as a quoted string.</p>
  4669. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4670. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  4671. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; &quot;.$db-&gt;DBTimeStamp(&quot;$year-$month-$day $hr:$min:$secs&quot;);</pre><pre><span
  4672. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute($sql);</pre></div>
  4673. <p><b>BindTimeStamp<a name=bindtimestamp></a>($ts)</b></p>
  4674. <p>Format the timestamp $<b>ts</b> in the bind format the database accepts.
  4675. Normally this means that the timestamp string is not quoted, unlike
  4676. DBTimeStamp, which quotes the string. </p>
  4677. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4678. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p>&nbsp;</o:p></pre><pre><span
  4679. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; &quot;.$db-&gt;Param('0');</pre><pre><span
  4680. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// or</pre><pre><span style='mso-tab-count:
  4681. 1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$sql = &quot;select * from atable where created &gt; ?&quot;;</pre><pre><span
  4682. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$db-&gt;Execute($sql,array($db-&gt;BindTimeStamp(&quot;$year-$month-$day $hr:$min:$secs&quot;));</pre></div>
  4683. <p><b>qstr<a name=qstr></a>($s,[$magic_quotes_enabled</b>=false]<b>)</b></p>
  4684. <p>Quotes a string to be sent to the database. The $<b>magic_quotes_enabled</b>
  4685. parameter may look funny, but the idea is if you are quoting a string extracted
  4686. from a POST/GET variable, then pass get_magic_quotes_gpc() as the second
  4687. parameter. This will ensure that the variable is not quoted twice, once by <i>qstr</i>
  4688. and once by the <i>magic_quotes_gpc</i>.</p>
  4689. <p>Eg.<span style='font-family:"Courier New"'> $s = $db-&gt;qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</span></p>
  4690. <p>Returns the quoted string.</p>
  4691. <p><b>Quote<a name=quote></a>($s)</b></p>
  4692. <p>Quotes the string $s, escaping the database specific quote character as
  4693. appropriate. Formerly checked magic quotes setting, but this was disabled since
  4694. 3.31 for compatibility with PEAR DB. </p>
  4695. <p><b>Affected_Rows<a name="affected_rows"></a>( )</b></p>
  4696. <p>Returns the number of rows affected by a update or delete statement. Returns
  4697. false if function not supported.</p>
  4698. <p>Not supported by interbase/firebird currently. </p>
  4699. <p><b>Insert_ID<a name="inserted_id"></a>( )</b></p>
  4700. <p>Returns the last autonumbering ID inserted. Returns false if function not
  4701. supported. </p>
  4702. <p>Only supported by databases that support auto-increment or object id's, such
  4703. as PostgreSQL, MySQL and MS SQL Server currently. PostgreSQL returns the OID,
  4704. which can change on a database reload.</p>
  4705. <p><b>RowLock<a name=rowlock></a>($table,$where)</b></p>
  4706. <p>Lock a table row for the duration of a transaction. For example to lock
  4707. record $id in table1: </p>
  4708. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4709. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4710. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;StartTrans();<br>
  4711. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;RowLock(&quot;table1&quot;,&quot;rowid=$id&quot;);<br>
  4712. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;Execute($sql1);<br>
  4713. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;Execute($sql2);<br>
  4714. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$DB-&gt;CompleteTrans();</pre></div>
  4715. <p>Supported in db2, interbase, informix, mssql, oci8, postgres, sybase. </p>
  4716. <p><b>MetaDatabases<a name=metadatabases></a>()</b></p>
  4717. <p>Returns a list of databases available on the server as an array. You have to
  4718. connect to the server first. Only available for ODBC, MySQL and ADO.</p>
  4719. <p><b>MetaTables<a name=metatables></a>($ttype = false, $showSchema = false,
  4720. $mask=false)</b></p>
  4721. <p>Returns an array of tables and views for the current database as an array.
  4722. The array should exclude system catalog tables if possible. To only show
  4723. tables, use $db-&gt;MetaTables('TABLES'). To show only views, use
  4724. $db-&gt;MetaTables('VIEWS'). The $showSchema parameter currently works only for
  4725. DB2, and when set to true, will add the schema name to the table, eg.
  4726. &quot;SCHEMA.TABLE&quot;. </p>
  4727. <p>You can define a mask for matching. For example, setting $mask = 'TMP%' will
  4728. match all tables that begin with 'TMP'. Currently only mssql, oci8, odbc_mssql
  4729. and postgres* support $mask. </p>
  4730. <p><b>MetaColumns<a name=metacolumns></a>($table,$notcasesensitive=true)</b></p>
  4731. <p>Returns an array of ADOFieldObject's, one field object for every column of
  4732. $table. A field object is a class instance with (name, type, max_length)
  4733. defined. Currently Sybase does not recognise date types, and ADO cannot
  4734. identify the correct data type (so we default to varchar). </p>
  4735. <p>The $notcasesensitive parameter determines whether we uppercase or lowercase
  4736. the table name to normalize it (required for some databases). Does not work
  4737. with MySQL ISAM tables. </p>
  4738. <p>For schema support, pass in the $table parameter,
  4739. &quot;$schema.$tablename&quot;. This is only supported for selected databases. </p>
  4740. <p><b>MetaColumnNames<a name=metacolumnames></a>($table,$numericIndex=false)</b></p>
  4741. <p>Returns an array of column names for $table. Since ADOdb 4.22, this is an
  4742. associative array, with the keys in uppercase. Set $numericIndex=true if you
  4743. want the old behaviour of numeric indexes (since 4.23). </p>
  4744. <p>e.g. array('FIELD1' =&gt; 'Field1', 'FIELD2'=&gt;'Field2') </p>
  4745. <p><b>MetaPrimaryKeys<a name=metaprimarykeys></a>($table, $owner=false)</b> </p>
  4746. <p>Returns an array containing column names that are the primary keys of
  4747. $table. Supported by mysql, odbc (including db2, odbc_mssql, etc), mssql,
  4748. postgres, interbase/firebird, oci8 currently. </p>
  4749. <p>Views (and some tables) have primary keys, but sometimes this information is
  4750. not available from the database. You can define a function
  4751. ADODB_View_PrimaryKeys($databaseType, $database, $view, $owner) that should
  4752. return an array containing the fields that make up the primary key. If that
  4753. function exists, it will be called when MetaPrimaryKeys() cannot find a primary
  4754. key for a table or view. </p>
  4755. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4756. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4757. style='background:#EEEEEE'>// In this example: dbtype = 'oci8', $db = 'mydb', $view = 'dataView', $owner = false <br>
  4758. function ADODB_View_PrimaryKeys($dbtype,$db,$view,$owner)<br>
  4759. {<br>
  4760. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>switch(strtoupper($view)) {<br>
  4761. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 'DATAVIEW': return array('DATAID');<br>
  4762. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>default: return false;<br>
  4763. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br>
  4764. }<br>
  4765. <br>
  4766. $db = NewADOConnection('oci8');<br>
  4767. $db-&gt;Connect('localhost','root','','mydb'); <br>
  4768. $db-&gt;MetaPrimaryKeys('dataView');</pre></div>
  4769. <p><b>ServerInfo<a name=serverinfo id=serverinfo></a>()</b> </p>
  4770. <p>Returns an array of containing two elements 'description' and 'version'. The
  4771. 'description' element contains the string description of the database. The
  4772. 'version' naturally holds the version number (which is also a string).</p>
  4773. <p><b>SetCharSet<a name=setcharset id=setcharset></a>($charset)</b> </p>
  4774. <p>Set the charset of the connection. The parameter passed in is dependent on the actual database RDBMS. e.g.
  4775. <pre>
  4776. $DB->SetCharSet('utf8'); // for mysql
  4777. </pre>
  4778. This is database driver specific and only supported for mysql, mysqlt, mysqli, and also postgres7 and later.</p>
  4779. <p><b>MetaForeignKeys<a name=metaforeignkeys></a>($table, $owner=false,
  4780. $upper=false)</b> </p>
  4781. <p>Returns an associate array of foreign keys, or false if not supported. For
  4782. example, if table employee has a foreign key where employee.deptkey points to
  4783. dept_table.deptid, and employee.posn=posn_table.postionid and
  4784. employee.poscategory=posn_table.category, then
  4785. $conn-&gt;MetaForeignKeys('employee') will return </p>
  4786. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4787. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4788. style='background:#EEEEEE'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>array(<br>
  4789. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'dept_table' =&gt; array('deptkey=deptid'),<br>
  4790. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>'posn_table' =&gt; array('posn=positionid','poscategory=category')<br>
  4791. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>)</pre></div>
  4792. <p>The optional schema or owner can be defined in $owner. If $upper is true,
  4793. then the table names (array keys) are upper-cased. </p>
  4794. <div class=MsoNormal align=center style='text-align:center'>
  4795. <hr size=2 width="100%" align=center>
  4796. </div>
  4797. <h2>ADORecordSet<a name=adorecordset></a></h2>
  4798. <p>When an SQL statement successfully is executed by <span style='font-family:
  4799. "Courier New"'>ADOConnection-&gt;Execute($sql),</span>an ADORecordSet object is
  4800. returned. This object contains a virtual cursor so we can move from row to row,
  4801. functions to obtain information about the columns and column types, and helper
  4802. functions to deal with formating the results to show to the user.</p>
  4803. <h3>ADORecordSet Fields</h3>
  4804. <p><b>fields: </b>Array containing the current row. This is not associative,
  4805. but is an indexed array from 0 to columns-1. See also the function <b><a
  4806. href="#fields">Fields</a></b>, which behaves like an associative array.</p>
  4807. <p><b>dataProvider</b>: The underlying mechanism used to connect to the
  4808. database. Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
  4809. <p><b>blobSize</b>: Maximum size of a char, string or varchar object before it
  4810. is treated as a Blob (Blob's should be shown with textarea's). See the <a
  4811. href="#metatype">MetaType</a> function.</p>
  4812. <p><b>sql</b>: Holds the sql statement used to generate this record set.</p>
  4813. <p><b>canSeek</b>: Set to true if Move( ) function works.</p>
  4814. <p><b>EOF</b>: True if we have scrolled the cursor past the last record.</p>
  4815. <h3>ADORecordSet Functions</h3>
  4816. <p><b>ADORecordSet( )</b></p>
  4817. <p>Constructer. Normally you never call this function yourself.</p>
  4818. <p><b>GetAssoc<a name=getassoc></a>([$force_array])</b></p>
  4819. <p>Generates an associative array from the recordset. Note that is this
  4820. function is also <a href="#getassoc1">available</a> in the connection object.
  4821. More details can be found there.</p>
  4822. <p><b>GetArray<a name=getarray></a>([$number_of_rows])</b></p>
  4823. <p>Generate a 2-dimensional array of records from the current cursor position,
  4824. indexed from 0 to $number_of_rows - 1. If $number_of_rows is undefined, till
  4825. EOF.</p>
  4826. <p><b>GetRows<a name=getrows></a>([$number_of_rows])</b></p>
  4827. <p class=MsoNormal>Generate a 2-dimensional array of records from the current
  4828. cursor position. Synonym for GetArray() for compatibility with Microsoft ADO. </p>
  4829. <p><b>GetMenu<a name=getmenu></a>($name, [$default_str=''],
  4830. [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
  4831. <p>Generate a HTML menu
  4832. (&lt;select&gt;&lt;option&gt;&lt;option&gt;&lt;/select&gt;). The first column
  4833. of the recordset (fields[0]) will hold the string to display in the option
  4834. tags. If the recordset has more than 1 column, the second column (fields[1]) is
  4835. the value to send back to the web server.. The menu will be given the name $<i>name</i>.
  4836. </p>
  4837. <p>If $<i>default_str</i> is defined, then if $<i>default_str</i> == fields[0],
  4838. that field is selected. If $<i>blank1stItem</i> is true, the first option is
  4839. empty. You can also set the first option strings by setting $blank1stItem =
  4840. &quot;$value:$text&quot;.</p>
  4841. <p>$<i>Default_str</i> can be array for a multiple select listbox.</p>
  4842. <p>To get a listbox, set the $<i>size</i> to a non-zero value (or pass
  4843. $default_str as an array). If $<i>multiple_select</i> is true then a listbox
  4844. will be generated with $<i>size</i> items (or if $size==0, then 5 items)
  4845. visible, and we will return an array to a server. Lastly use $<i>moreAttr </i>to
  4846. add additional attributes such as javascript or styles. </p>
  4847. <p>Menu Example 1: <code><span style='font-size:10.0pt'>GetMenu('menu1','A',true)</span></code>
  4848. will generate a menu: <SELECT NAME="menu1">
  4849. <OPTION>
  4850. <OPTION SELECTED VALUE="1">A
  4851. <OPTION VALUE="2">B
  4852. <OPTION VALUE="3">C
  4853. </SELECT>for
  4854. the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p>
  4855. <p>Menu Example 2: For the same data, <code><span style='font-size:10.0pt'>GetMenu('menu1',array('A','B'),false)</span></code>
  4856. will generate a menu with both A and B selected: <br>
  4857. <SELECT MULTIPLE NAME="menu1" SIZE="3">
  4858. <OPTION SELECTED VALUE="1">A
  4859. <OPTION SELECTED VALUE="2">B
  4860. <OPTION VALUE="3">C
  4861. </SELECT></p>
  4862. <p><b>GetMenu2<a name=getmenu2></a>($name, [$default_str=''],
  4863. [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
  4864. <p>This is nearly identical to GetMenu, except that the $<i>default_str</i> is
  4865. matched to fields[1] (the option values).</p>
  4866. <p>Menu Example 3: Given the data in menu example 2, <code><span
  4867. style='font-size:10.0pt'>GetMenu2('menu1',array('1','2'),false)</span></code>
  4868. will generate a menu with both A and B selected in menu example 2, but this
  4869. time the selection is based on the 2nd column, which holds the values to return
  4870. to the Web server. </p>
  4871. <p><b>UserDate<a name=userdate></a>($str, [$fmt])</b></p>
  4872. <p>Converts the date string $<i>str</i> to another format. The date format is
  4873. Y-m-d, or Unix timestamp format. The default $<i>fmt</i> is Y-m-d.</p>
  4874. <p><b>UserTimeStamp<a name=usertimestamp></a>($str, [$fmt])</b></p>
  4875. <p>Converts the timestamp string $<b>str</b> to another format. The timestamp
  4876. format is Y-m-d H:i:s, as in '2002-02-28 23:00:12', or Unix timestamp format.
  4877. UserTimeStamp calls UnixTimeStamp to parse $<i>str</i>, and $<i>fmt</i>
  4878. defaults to Y-m-d H:i:s if not defined. </p>
  4879. <p><b>UnixDate<a name=unixdate></a>($str)</b></p>
  4880. <p>Parses the date string $<b>str</b> and returns it in unix mktime format (eg.
  4881. a number indicating the seconds after January 1st, 1970). Expects the date to
  4882. be in Y-m-d H:i:s format, except for Sybase and Microsoft SQL Server, where M d
  4883. Y is also accepted (the 3 letter month strings are controlled by a global
  4884. array, which might need localisation).</p>
  4885. <p>This function is available in both ADORecordSet and ADOConnection since
  4886. 1.91.</p>
  4887. <p><b>UnixTimeStamp<a name=unixtimestamp></a>($str)</b></p>
  4888. <p>Parses the timestamp string $<b>str</b> and returns it in unix mktime format
  4889. (eg. a number indicating the seconds after January 1st, 1970). Expects the date
  4890. to be in &quot;Y-m-d, H:i:s&quot; (1970-12-24, 00:00:00) or &quot;Y-m-d
  4891. H:i:s&quot; (1970-12-24 00:00:00) or &quot;YmdHis&quot; (19701225000000)
  4892. format, except for Sybase and Microsoft SQL Server, where &quot;M d Y
  4893. h:i:sA&quot; (Dec 25 1970 00:00:00AM) is also accepted (the 3 letter month
  4894. strings are controlled by a global array, which might need localisation).</p>
  4895. <p>This function is available in both ADORecordSet and ADOConnection since
  4896. 1.91. </p>
  4897. <p><b>OffsetDate<a name=OffsetDate></a>($dayFraction, $basedate=false)</b></p>
  4898. <p>Returns a string with the native SQL functions to calculate future and past
  4899. dates based on $basedate in a portable fashion. If $basedate is not defined,
  4900. then the current date (at 12 midnight) is used. Returns the SQL string that
  4901. performs the calculation when passed to Execute(). </p>
  4902. <p>For example, in Oracle, to find the date and time that is 2.5 days from
  4903. today, you can use:</p>
  4904. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4905. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4906. style='background:#EEEEEE'># get date one week from now<br>
  4907. $fld = $conn-&gt;OffsetDate(7); // returns &quot;(trunc(sysdate)+7&quot;)</pre><pre># get date and time that is 60 hours from current date and time<br>
  4908. $fld = $conn-&gt;OffsetDate(2.5, $conn-&gt;sysTimeStamp);<span
  4909. style='mso-tab-count:1'> </span>// returns &quot;(sysdate+2.5)&quot;<br>
  4910. <br>
  4911. $conn-&gt;Execute(&quot;UPDATE TABLE SET dodate=$fld WHERE ID=$id&quot;);</pre></div>
  4912. <p>This function is available for mysql, mssql, oracle, oci8 and postgresql
  4913. drivers since 2.13. It might work with other drivers provided they allow
  4914. performing numeric day arithmetic on dates.</p>
  4915. <p><b>SQLDate<a name=sqldate></a>($dateFormat, $basedate=false)</b></p>
  4916. <p class=MsoNormal>Returns a string which contains the native SQL functions to
  4917. format a date or date column $basedate. This is used when retrieving date
  4918. columns in SELECT statements. For sending dates to the database (eg. in UPDATE,
  4919. INSERT or the where clause of SELECT statements) use <a href="#dbdate">DBDate</a>.
  4920. It uses a case-sensitive $dateFormat, which supports: </p>
  4921. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4922. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span style='mso-spacerun:yes'>&nbsp;</span></pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>Y: 4-digit Year</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>Q: Quarter (1-4)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>M: Month (Jan-Dec)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>m: Month (01-12)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>d: Day (01-31)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>H: Hour (00-23)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>h: Hour (1-12)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>i: Minute (00-59)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>s: Second (00-60)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>A: AM/PM indicator</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>w: day of week (0-6 or 1-7 depending on DB)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>l: day of week (as string - lowercase L)</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span>W: week in year (0..53 for MySQL, 1..53 for PostgreSQL and Oracle)</pre><pre
  4923. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp; </span></pre></div>
  4924. <p>All other characters are treated as strings. You can also use \ to escape
  4925. characters. Available on selected databases, including mysql, postgresql,
  4926. mssql, oci8 and DB2. </p>
  4927. <p>This is useful in writing portable sql statements that GROUP BY on dates.
  4928. For example to display total cost of goods sold broken by quarter (dates are
  4929. stored in a field called postdate): </p>
  4930. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4931. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4932. style='background:#EEEEEE'><span style='mso-spacerun:yes'>&nbsp;</span>$sqlfn = $db-&gt;SQLDate('Y-\QQ','postdate'); # get sql that formats postdate to output 2002-Q1<br>
  4933. <span style='mso-spacerun:yes'>&nbsp;</span>$sql = &quot;SELECT $sqlfn,SUM(cogs) FROM table GROUP BY $sqlfn ORDER BY 1 desc&quot;;<br>
  4934. <span style='mso-spacerun:yes'>&nbsp;</span></pre></div>
  4935. <p><b>MoveNext<a name=movenext></a>( )</b></p>
  4936. <p>Move the internal cursor to the next row. The <i>$this-&gt;fields</i> array
  4937. is automatically updated. Returns false if unable to do so (normally because
  4938. EOF has been reached), otherwise true. </p>
  4939. <p>If EOF is reached, then the $this-&gt;fields array is set to false (this was
  4940. only implemented consistently in ADOdb 3.30). For the pre-3.30 behaviour of
  4941. $this-&gt;fields (at EOF), set the global variable $ADODB_COMPAT_FETCH = true.</p>
  4942. <p>Example:</p>
  4943. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  4944. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  4945. style='background:#EEEEEE'>$rs = $db-&gt;Execute($sql);<br>
  4946. if ($rs) <br>
  4947. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>while (!$rs-&gt;EOF) {<br>
  4948. <span style='mso-spacerun:yes'>&nbsp;</span><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ProcessArray($rs-&gt;fields);<span
  4949. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  4950. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$rs-&gt;MoveNext();<br>
  4951. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>} </pre></div>
  4952. <p><b>Move<a name=move></a>($to)</b></p>
  4953. <p>Moves the internal cursor to a specific row $<b>to</b>. Rows are zero-based
  4954. eg. 0 is the first row. The <b>fields</b> array is automatically updated. For
  4955. databases that do not support scrolling internally, ADOdb will simulate forward
  4956. scrolling. Some databases do not support backward scrolling. If the $<b>to</b>
  4957. position is after the EOF, $<b>to</b> will move to the end of the RecordSet for
  4958. most databases. Some obscure databases using odbc might not behave this way.</p>
  4959. <p>Note: This function uses <i>absolute positioning</i>, unlike Microsoft's
  4960. ADO.</p>
  4961. <p>Returns true or false. If false, the internal cursor is not moved in most
  4962. implementations, so AbsolutePosition( ) will return the last cursor position
  4963. before the Move( ). </p>
  4964. <p><b>MoveFirst<a name=movefirst></a>()</b></p>
  4965. <p>Internally calls Move(0). Note that some databases do not support this function.</p>
  4966. <p><b>MoveLast<a name=movelast></a>()</b></p>
  4967. <p>Internally calls Move(RecordCount()-1). Note that some databases do not
  4968. support this function.</p>
  4969. <p><b>GetRowAssoc</b><a name=getrowassoc></a>($toUpper=true)</p>
  4970. <p>Returns an associative array containing the current row. The keys to the
  4971. array are the column names. The column names are upper-cased for easy access.
  4972. To get the next row, you will still need to call MoveNext(). </p>
  4973. <p>For example:<br>
  4974. Array ( [ID] =&gt; 1 [FIRSTNAME] =&gt; Caroline [LASTNAME] =&gt; Miranda
  4975. [CREATED] =&gt; 2001-07-05 ) </p>
  4976. <p>Note: do not use GetRowAssoc() with $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC.
  4977. Because they have the same functionality, they will interfere with each other.</p>
  4978. <p><b>AbsolutePage<a name=absolutepage></a>($page=-1) </b></p>
  4979. <p>Returns the current page. Requires PageExecute()/CachePageExecute() to be
  4980. called. See <a href="#ex8">Example 8</a>.</p>
  4981. <p><b>AtFirstPage<a name=atfirstpage>($status='')</a></b><span
  4982. style='mso-bookmark:atfirstpage'></span></p>
  4983. <p>Returns true if at first page (1-based). Requires
  4984. PageExecute()/CachePageExecute() to be called. See <a href="#ex8">Example 8</a>.</p>
  4985. <p><b>AtLastPage<a name=atlastpage>($status='')</a></b><span style='mso-bookmark:
  4986. atlastpage'></span></p>
  4987. <p>Returns true if at last page (1-based). Requires
  4988. PageExecute()/CachePageExecute() to be called. See <a href="#ex8">Example 8</a>.</p>
  4989. <p><b>Fields</b><a name=fields></a>(<b>$colname</b>)</p>
  4990. <p>Returns the value of the associated column $<b>colname</b> for the current
  4991. row. The column name is case-insensitive.</p>
  4992. <p>This is a convenience function. For higher performance, use <a
  4993. href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>. </p>
  4994. <p><b>FetchRow</b><a name=fetchrow></a>()</p>
  4995. <p>Returns array containing current row, or false if EOF. FetchRow( )
  4996. internally moves to the next record after returning the current row. </p>
  4997. <p>Warning: Do not mix using FetchRow() with MoveNext().</p>
  4998. <p>Usage:</p>
  4999. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  5000. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  5001. style='background:#EEEEEE'>$rs = $db-&gt;Execute($sql);<br>
  5002. if ($rs)<br>
  5003. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>while ($arr = $rs-&gt;FetchRow()) {<br>
  5004. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>&nbsp;&nbsp;# process $arr<span
  5005. style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br>
  5006. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</pre></div>
  5007. <p><b>FetchInto</b><a name=fetchinto></a>(<b>&amp;$array</b>)</p>
  5008. <p>Sets $array to the current row. Returns PEAR_Error object if EOF, 1 if ok
  5009. (DB_OK constant). If PEAR is undefined, false is returned when EOF. FetchInto(
  5010. ) internally moves to the next record after returning the current row. </p>
  5011. <p>FetchRow() is easier to use. See above.</p>
  5012. <p><b>FetchField<a name=fetchfield></a>($column_number)</b></p>
  5013. <p>Returns an object containing the <b>name</b>, <b>type</b> and <b>max_length</b>
  5014. of the associated field. If the max_length cannot be determined reliably, it
  5015. will be set to -1. The column numbers are zero-based. See <a href="#ex2">example
  5016. 2.</a></p>
  5017. <p><b>FieldCount<a name=fieldcount></a>( )</b></p>
  5018. <p>Returns the number of fields (columns) in the record set.</p>
  5019. <p><b>RecordCount<a name=recordcount></a>( )</b></p>
  5020. <p>Returns the number of rows in the record set. If the number of records
  5021. returned cannot be determined from the database driver API, we will buffer all
  5022. rows and return a count of the rows after all the records have been retrieved.
  5023. This buffering can be disabled (for performance reasons) by setting the global
  5024. variable $ADODB_COUNTRECS = false. When disabled, RecordCount( ) will return -1
  5025. for certain databases. See the supported databases list above for more details.
  5026. </p>
  5027. <p>RowCount is a synonym for RecordCount.</p>
  5028. <p><b>PO_RecordCount<a name="po_recordcount"></a>($table, $where)</b></p>
  5029. <p>Returns the number of rows in the record set. If the database does not
  5030. support this, it will perform a SELECT COUNT(*) on the table $table, with the
  5031. given $where condition to return an estimate of the recordset size.</p>
  5032. <p>$numrows = $rs-&gt;PO_RecordCount(&quot;articles_table&quot;,
  5033. &quot;group=$group&quot;);</p>
  5034. <p class=MsoNormal><b>NextRecordSet<a name=nextrecordset id=nextrecordset></a>()</b>
  5035. </p>
  5036. <p>For databases that allow multiple recordsets to be returned in one query,
  5037. this function allows you to switch to the next recordset. Currently only
  5038. supported by mssql driver.</p>
  5039. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  5040. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  5041. style='background:#EEEEEE'>$rs = $db-&gt;Execute('execute return_multiple_rs');<br>
  5042. $arr1 = $rs-&gt;GetArray();<br>
  5043. $rs-&gt;NextRecordSet();<br>
  5044. $arr2 = $rs-&gt;GetArray();</pre></div>
  5045. <p><b>FetchObject<a name=fetchobject></a>($toupper=true)</b></p>
  5046. <p>Returns the current row as an object. If you set $toupper to true, then the
  5047. object fields are set to upper-case. Note: The newer FetchNextObject() is the
  5048. recommended way of accessing rows as objects. See below.</p>
  5049. <p><b>FetchNextObject<a name=fetchnextobject></a>($toupper=true)</b></p>
  5050. <p>Gets the current row as an object and moves to the next row automatically.
  5051. Returns false if at end-of-file. If you set $toupper to true, then the object
  5052. fields are set to upper-case. Note that for some drivers such as mssql, you
  5053. need to SetFetchMode(ADODB_FETCH_ASSOC) or SetFetchMode(ADODB_FETCH_BOTH).</p>
  5054. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  5055. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  5056. style='background:#EEEEEE'>$rs = $db-&gt;Execute('select firstname,lastname from table');<br>
  5057. if ($rs) {<br>
  5058. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>while ($o = $rs-&gt;FetchNextObject()) {<br>
  5059. <span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>print &quot;$o-&gt;FIRSTNAME, $o-&gt;LASTNAME&lt;BR&gt;&quot;;<br>
  5060. <span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br>
  5061. }</pre></div>
  5062. <p>There is some trade-off in speed in using FetchNextObject(). If performance
  5063. is important, you should access rows with the <code><span style='font-size:
  5064. 10.0pt'>fields[]</span></code> array. <b>FetchObj<a name=fetchobj id=fetchobj></a>()</b>
  5065. </p>
  5066. <p>Returns the current record as an object. Fields are not upper-cased, unlike
  5067. FetchObject. </p>
  5068. <p><b>FetchNextObj<a name=fetchnextobj id=fetchnextobj></a>()</b> </p>
  5069. <p>Returns the current record as an object and moves to the next record. If
  5070. EOF, false is returned. Fields are not upper-cased, unlike FetctNextObject. </p>
  5071. <p><b>CurrentRow<a name=currentrow></a>( )</b></p>
  5072. <p>Returns the current row of the record set. 0 is the first row.</p>
  5073. <p><b>AbsolutePosition<a name=abspos></a>( )</b></p>
  5074. <p>Synonym for <b>CurrentRow</b> for compatibility with ADO. Returns the
  5075. current row of the record set. 0 is the first row.</p>
  5076. <p><b>MetaType<a name=metatype></a>($nativeDBType[,$field_max_length],[$fieldobj])</b></p>
  5077. <p>Determine what <i>generic</i> meta type a database field type is given its
  5078. native type $<b>nativeDBType</b> as a string and the length of the field $<b>field_max_length</b>.
  5079. Note that field_max_length can be -1 if it is not known. The field object
  5080. returned by FetchField() can be passed in $<b>fieldobj</b> or as the 1st
  5081. parameter <b>$nativeDBType</b>. This is useful for databases such as <i>mysql</i>
  5082. which has additional properties in the field object such as <i>primary_key</i>.
  5083. </p>
  5084. <p>Uses the field <b>blobSize</b> and compares it with $<b>field_max_length</b>
  5085. to determine whether the character field is actually a blob.</p>
  5086. <p class=MsoNormal>For example, $db-&gt;MetaType('char') will return 'C'. </p>
  5087. <p>Returns:</p>
  5088. <ul type=disc>
  5089. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5090. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>C</b>: Character fields
  5091. that should be shown in a &lt;input type=&quot;text&quot;&gt; tag. </li>
  5092. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5093. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>X</b>: Clob (character
  5094. large objects), or large text fields that should be shown in a
  5095. &lt;textarea&gt;</li>
  5096. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5097. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>D</b>: Date field</li>
  5098. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5099. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>T</b>: Timestamp field</li>
  5100. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5101. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>L</b>: Logical field
  5102. (boolean or bit-field)</li>
  5103. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5104. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>N</b>: Numeric field.
  5105. Includes decimal, numeric, floating point, and real. </li>
  5106. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5107. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>I</b>:&nbsp; Integer
  5108. field. </li>
  5109. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5110. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>R</b>: Counter or
  5111. Autoincrement field. Must be numeric.</li>
  5112. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5113. mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>B</b>: Blob, or binary
  5114. large objects. </li>
  5115. </ul>
  5116. <p>Since ADOdb 3.0, MetaType accepts $fieldobj as the first parameter, instead
  5117. of $nativeDBType. </p>
  5118. <p><b>Close( )</b><a name=rsclose></a></p>
  5119. <p>Closes the recordset, cleaning all memory and resources associated with the
  5120. recordset. </p>
  5121. <p>If memory management is not an issue, you do not need to call this function
  5122. as recordsets are closed for you by PHP at the end of the script. SQL
  5123. statements such as INSERT/UPDATE/DELETE do not really return a recordset, so you
  5124. do not have to call Close() for such SQL statements.</p>
  5125. <div class=MsoNormal align=center style='text-align:center'>
  5126. <hr size=2 width="100%" align=center>
  5127. </div>
  5128. <h3>function rs2html<a name=rs2html></a>($adorecordset,[$tableheader_attributes],
  5129. [$col_titles])</h3>
  5130. <p>This is a standalone function (rs2html = recordset to html) that is similar
  5131. to PHP's <i>odbc_result_all</i> function, it prints a ADORecordSet, $<b>adorecordset</b>
  5132. as a HTML table. $<b>tableheader_attributes</b> allow you to control the table <i>cellpadding</i>,
  5133. <i>cellspacing</i> and <i>border</i> attributes. Lastly you can replace the
  5134. database column names with your own column titles with the array $<b>col_titles</b>.
  5135. This is designed more as a quick debugging mechanism, not a production table
  5136. recordset viewer.</p>
  5137. <p>You will need to include the file <i>tohtml.inc.php</i>.</p>
  5138. <p>Example of rs2html:<a name=exrs2html></a></p>
  5139. <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
  5140. solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
  5141. style='background:#EEEEEE'><b><span style='color:#336600'>&lt;?<br>
  5142. include('tohtml.inc.php')</span></b>; # load code common to ADOdb <br>
  5143. <b>include</b>('adodb.inc.php'); # load code common to ADOdb <br>
  5144. $<span style='color:#663300'>conn</span> = &amp;ADONewConnection('mysql');<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span># create a connection <br>
  5145. $<span style='color:#663300'>conn</span>-&gt;PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
  5146. $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers'; <br>
  5147. $<span style='color:#663300'>rs</span><span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>= $<span
  5148. style='color:#663300'>conn</span>-&gt;Execute($sql); <br>
  5149. <b><span style='color:#336600'>rs2html</span>($</b><b><span style='color:#663300'>rs</span>,'<i>border=2 cellpadding=3</i>',array('<i>Customer Name','Customer ID</i>'));<br>
  5150. ?&gt;</b></pre></div>
  5151. <div class=MsoNormal align=center style='text-align:center'>
  5152. <hr size=2 width="100%" align=center>
  5153. </div>
  5154. <h3>Differences between this ADOdb library and Microsoft ADO<a name=adodiff></a></h3>
  5155. <ol start=1 type=1>
  5156. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5157. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADOdb only supports
  5158. recordsets created by a connection object. Recordsets cannot be created
  5159. independently.</li>
  5160. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5161. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADO properties are implemented
  5162. as functions in ADOdb. This makes it easier to implement any enhanced ADO
  5163. functionality in the future.</li>
  5164. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5165. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADOdb's <span
  5166. style='font-family:"Courier New"'>ADORecordSet-&gt;Move()</span> uses
  5167. absolute positioning, not relative. Bookmarks are not supported.</li>
  5168. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5169. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'><span style='font-family:
  5170. "Courier New"'>ADORecordSet-&gt;AbsolutePosition() </span>cannot be used
  5171. to move the record cursor.</li>
  5172. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5173. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADO Parameter objects are
  5174. not supported. Instead we have the ADOConnection::<a href="#parameter">Parameter</a>(
  5175. ) function, which provides a simpler interface for calling preparing
  5176. parameters and calling stored procedures.</li>
  5177. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  5178. mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>Recordset properties for
  5179. paging records are available, but implemented as in <a href="#ex8">Example
  5180. 8</a>.</li>
  5181. </ol>
  5182. <div class=MsoNormal align=center style='text-align:center'>
  5183. <hr size=2 width="100%" align=center>
  5184. </div>
  5185. <h1>Database Driver Guide<a name=driverguide></a></h1>
  5186. <p>This describes how to create a class to connect to a new database. To ensure
  5187. there is no duplication of work, kindly email me at jlim#natsoft.com if you
  5188. decide to create such a class.</p>
  5189. <p>First decide on a name in lower case to call the database type. Let's say we
  5190. call it xbase. </p>
  5191. <p>Then we need to create two classes ADODB_xbase and ADORecordSet_xbase in the
  5192. file adodb-xbase.inc.php.</p>
  5193. <p>The simplest form of database driver is an adaptation of an existing ODBC
  5194. driver. Then we just need to create the class <i>ADODB_xbase extends ADODB_odbc</i>
  5195. to support the new <b>date</b> and <b>timestamp</b> formats, the <b>concatenation</b>
  5196. operator used, <b>true</b> and <b>false</b>. For the<i> ADORecordSet_xbase
  5197. extends ADORecordSet_odbc </i>we need to change the <b>MetaType</b> function.
  5198. See<b> adodb-vfp.inc.php</b> as an example.</p>
  5199. <p>More complicated is a totally new database driver that connects to a new PHP
  5200. extension. Then you will need to implement several functions. Fortunately, you
  5201. do not have to modify most of the complex code. You only need to override a few
  5202. stub functions. See <b>adodb-mysql.inc.php</b> for example.</p>
  5203. <p>The default date format of ADOdb internally is YYYY-MM-DD (Ansi-92). All
  5204. dates should be converted to that format when passing to an ADOdb date
  5205. function. See Oracle for an example how we use ALTER SESSION to change the
  5206. default date format in _pconnect _connect.</p>
  5207. <p><b>ADOConnection Functions to Override</b></p>
  5208. <p>Defining a constructor for your ADOConnection derived function is optional.
  5209. There is no need to call the base class constructor.</p>
  5210. <p>_<b>connect</b>: Low level implementation of Connect. Returns true or false.
  5211. Should set the _<b>connectionID</b>.</p>
  5212. <p>_<b>pconnect:</b> Low level implemention of PConnect. Returns true or false.
  5213. Should set the _<b>connectionID</b>.</p>
  5214. <p>_<b>query</b>: Execute a query. Returns the queryID, or false.</p>
  5215. <p>_<b>close: </b>Close the connection -- PHP should clean up all recordsets. </p>
  5216. <p><b>ErrorMsg</b>: Stores the error message in the private variable _errorMsg.
  5217. </p>
  5218. <p><b>ADOConnection Fields to Set</b></p>
  5219. <p>_<b>bindInputArray</b>: Set to true if binding of parameters for SQL inserts
  5220. and updates is allowed using ?, eg. as with ODBC.</p>
  5221. <p><b>fmtDate</b></p>
  5222. <p><b>fmtTimeStamp</b></p>
  5223. <p><b>true</b></p>
  5224. <p><b>false</b></p>
  5225. <p><b>concat_operator</b></p>
  5226. <p><b>replaceQuote</b></p>
  5227. <p><b>hasLimit</b> support SELECT * FROM TABLE LIMIT 10 of MySQL.</p>
  5228. <p><b>hasTop</b> support Microsoft style SELECT TOP 10 * FROM TABLE.</p>
  5229. <p><b>ADORecordSet Functions to Override</b></p>
  5230. <p>You will need to define a constructor for your ADORecordSet derived class
  5231. that calls the parent class constructor.</p>
  5232. <p><b>FetchField: </b>as documented above in ADORecordSet</p>
  5233. <p>_<b>initrs</b>: low level initialization of the recordset: setup the _<b>numOfRows</b>
  5234. and _<b>numOfFields</b> fields -- called by the constructor.</p>
  5235. <p>_<b>seek</b>: seek to a particular row. Do not load the data into the fields
  5236. array. This is done by _fetch. Returns true or false. Note that some
  5237. implementations such as Interbase do not support seek. Set canSeek to false.</p>
  5238. <p>_<b>fetch</b>: fetch a row using the database extension function and then
  5239. move to the next row. Sets the <b>fields</b> array. If the parameter
  5240. $ignore_fields is true then there is no need to populate the <b>fields</b>
  5241. array, just move to the next row. then Returns true or false.</p>
  5242. <p>_<b>close</b>: close the recordset</p>
  5243. <p><b>Fields</b>: If the array row returned by the PHP extension is not an
  5244. associative one, you will have to override this. See adodb-odbc.inc.php for an
  5245. example. For databases such as MySQL and MSSQL where an associative array is
  5246. returned, there is no need to override this function.</p>
  5247. <p><b>ADOConnection Fields to Set</b></p>
  5248. <p>canSeek: Set to true if the _seek function works.</p>
  5249. <h2>Optimizing PHP</h2>
  5250. <p class=MsoNormal>For info on tuning PHP, read this article on <a
  5251. href="http://phplens.com/lens/php-book/optimizing-debugging-php.php">Optimizing
  5252. PHP</a>. </p>
  5253. </div>
  5254. </body>
  5255. </html>