123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911 |
- <?php
-
- require_once 'PEAR.php';
- define('DB_DATAOBJECT_FETCHMODE_ORDERED',1);
- define('DB_DATAOBJECT_FETCHMODE_ASSOC',2);
- define('DB_DATAOBJECT_INT', 1);
- define('DB_DATAOBJECT_STR', 2);
- define('DB_DATAOBJECT_DATE', 4);
- define('DB_DATAOBJECT_TIME', 8);
- define('DB_DATAOBJECT_BOOL', 16);
- define('DB_DATAOBJECT_TXT', 32);
- define('DB_DATAOBJECT_BLOB', 64);
- define('DB_DATAOBJECT_NOTNULL', 128);
- define('DB_DATAOBJECT_MYSQLTIMESTAMP' , 256);
- define('DB_DATAOBJECT_ERROR_INVALIDARGS', -1);
- define('DB_DATAOBJECT_ERROR_NODATA', -2);
- define('DB_DATAOBJECT_ERROR_INVALIDCONFIG', -3);
- define('DB_DATAOBJECT_ERROR_NOCLASS', -4);
- define('DB_DATAOBJECT_ERROR_INVALID_CALL' ,-7);
- define('DB_DATAOBJECT_WHEREADD_ONLY', true);
- $GLOBALS['_DB_DATAOBJECT']['RESULTS'] = array();
- $GLOBALS['_DB_DATAOBJECT']['RESULTSEQ'] = 1;
- $GLOBALS['_DB_DATAOBJECT']['RESULTFIELDS'] = array();
- $GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'] = array();
- $GLOBALS['_DB_DATAOBJECT']['INI'] = array();
- $GLOBALS['_DB_DATAOBJECT']['LINKS'] = array();
- $GLOBALS['_DB_DATAOBJECT']['SEQUENCE'] = array();
- $GLOBALS['_DB_DATAOBJECT']['LASTERROR'] = null;
- $GLOBALS['_DB_DATAOBJECT']['CONFIG'] = array();
- $GLOBALS['_DB_DATAOBJECT']['CACHE'] = array();
- $GLOBALS['_DB_DATAOBJECT']['OVERLOADED'] = false;
- $GLOBALS['_DB_DATAOBJECT']['QUERYENDTIME'] = 0;
-
-
- if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
-
- class DB_DataObject_Overload
- {
- function __call($method,$args)
- {
- $return = null;
- $this->_call($method,$args,$return);
- return $return;
- }
- function __sleep()
- {
- return array_keys(get_object_vars($this)) ;
- }
- }
- } else {
- class DB_DataObject_Overload {}
- }
-
-
-
-
- class DB_DataObject extends DB_DataObject_Overload
- {
-
- var $_DB_DataObject_version = "1.11.3";
-
- var $__table = '';
-
- var $N = 0;
-
-
-
-
-
- function get($k = null, $v = null)
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- $keys = array();
-
- if ($v === null) {
- $v = $k;
- $keys = $this->keys();
- if (!$keys) {
- $this->raiseError("No Keys available for {$this->tableName()}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- $k = $keys[0];
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("$k $v " .print_r($keys,true), "GET");
- }
-
- if ($v === null) {
- $this->raiseError("No Value specified for get", DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- $this->$k = $v;
- return $this->find(1);
- }
-
-
- function pid()
- {
- $keys = $this->keys();
- if (!$keys) {
- $this->raiseError("No Keys available for {$this->tableName()}",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- $k = $keys[0];
- if (empty($this->$k)) {
- $this->raiseError("pid() called on Object where primary key value not available",
- DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
- return $this->$k;
- }
-
-
-
- function _build_select()
- {
- global $_DB_DATAOBJECT;
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
- if ($quoteIdentifiers) {
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- }
- $tn = ($quoteIdentifiers ? $DB->quoteIdentifier($this->tableName()) : $this->tableName()) ;
- if (!empty($this->_query['derive_table']) && !empty($this->_query['derive_select']) ) {
-
-
-
-
- $sql = 'SELECT ' .
- $this->_query['derive_select']
- .' FROM ( SELECT'.
- $this->_query['data_select'] . " \n" .
- " FROM $tn " . $this->_query['useindex'] . " \n" .
- $this->_join . " \n" .
- $this->_query['condition'] . " \n" .
- $this->_query['group_by'] . " \n" .
- $this->_query['having'] . " \n" .
- ') ' . $this->_query['derive_table'];
-
- return $sql;
-
-
- }
-
-
-
- $sql = 'SELECT ' .
- $this->_query['data_select'] . " \n" .
- " FROM $tn " . $this->_query['useindex'] . " \n" .
- $this->_join . " \n" .
- $this->_query['condition'] . " \n" .
- $this->_query['group_by'] . " \n" .
- $this->_query['having'] . " \n";
-
- return $sql;
- }
-
-
- function find($n = false)
- {
- global $_DB_DATAOBJECT;
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
-
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug($n, "find",1);
- }
- if (!$this->__table) {
-
- trigger_error("NO \$__table SPECIFIED in class definition",E_USER_ERROR);
- }
- $this->N = 0;
- $query_before = $this->_query;
- $this->_build_condition($this->table()) ;
-
-
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
-
- $sql = $this->_build_select();
-
- foreach ($this->_query['unions'] as $union_ar) {
- $sql .= $union_ar[1] . $union_ar[0]->_build_select() . " \n";
- }
-
- $sql .= $this->_query['order_by'] . " \n";
-
-
-
- if ((!isset($_DB_DATAOBJECT['CONFIG']['db_driver'])) ||
- ($_DB_DATAOBJECT['CONFIG']['db_driver'] == 'DB')) {
-
-
- if (isset($this->_query['limit_start']) && strlen($this->_query['limit_start'] . $this->_query['limit_count'])) {
- $sql = $DB->modifyLimitQuery($sql,$this->_query['limit_start'], $this->_query['limit_count']);
- }
- } else {
-
- if (isset($this->_query['limit_start']) && strlen($this->_query['limit_start'] . $this->_query['limit_count'])) {
- $DB->setLimit($this->_query['limit_count'],$this->_query['limit_start']);
- }
- }
-
-
- $err = $this->_query($sql);
- if (is_a($err,'PEAR_Error')) {
- return false;
- }
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("CHECK autofetchd $n", "find", 1);
- }
-
-
-
- $ret = $this->N;
- if (!$ret && !empty($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) {
-
- unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]);
- }
-
- if ($n && $this->N > 0 ) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("ABOUT TO AUTOFETCH", "find", 1);
- }
- $fs = $this->fetch();
-
-
- $ret = ($ret === true) ? $fs : $ret;
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("DONE", "find", 1);
- }
- $this->_query = $query_before;
- return $ret;
- }
-
- function fetch()
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- if (empty($this->N)) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("No data returned from FIND (eg. N is 0)","FETCH", 3);
- }
- return false;
- }
-
- if (empty($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]) ||
- !is_object($result = $_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]))
- {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug('fetched on object after fetch completed (no results found)');
- }
- return false;
- }
-
-
- $array = $result->fetchRow(DB_DATAOBJECT_FETCHMODE_ASSOC);
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug(serialize($array),"FETCH");
- }
-
-
- if ($array === null) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $t= explode(' ',microtime());
-
- $this->debug("Last Data Fetch'ed after " .
- ($t[0]+$t[1]- $_DB_DATAOBJECT['QUERYENDTIME'] ) .
- " seconds",
- "FETCH", 1);
- }
-
- unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]);
-
-
-
-
- if (!empty($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) {
- $this->_resultFields = $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid];
- unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]);
- }
-
-
- return false;
- }
-
- $this->_resultFields = false;
-
- if (!isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) {
-
- $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]= array_flip(array_keys($array));
- }
- $replace = array('.', ' ');
- foreach($array as $k=>$v) {
-
- $kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
- $k : str_replace($replace, '_', $k);
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("$kk = ". $array[$k], "fetchrow LINE", 3);
- }
- $this->$kk = $array[$k];
- }
-
-
- $this->_link_loaded=false;
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("{$this->tableName()} DONE", "fetchrow",2);
- }
- if (($this->_query !== false) && empty($_DB_DATAOBJECT['CONFIG']['keep_query_after_fetch'])) {
- $this->_query = false;
- }
- return true;
- }
-
-
- function fetchAll($k= false, $v = false, $method = false)
- {
-
- if ($k !== false &&
- (
- empty($this->_query['data_select']) ||
- ($this->_query['data_select'] == '*')
- )
- ) {
- $this->selectAdd();
- $this->selectAdd($k);
- if ($v !== false) {
- $this->selectAdd($v);
- }
- }
-
- $this->find();
- $ret = array();
- while ($this->fetch()) {
- if ($v !== false) {
- $ret[$this->$k] = $this->$v;
- continue;
- }
- $ret[] = $k === false ?
- ($method == false ? clone($this) : $this->$method())
- : $this->$k;
- }
- return $ret;
-
- }
-
-
-
- function whereAdd($cond = false, $logic = 'AND')
- {
-
- $_query = $this->_query;
-
- if (!isset($this->_query) || ($_query === false)) {
- return $this->raiseError(
- "You cannot do two queries on the same object (clone it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
-
- if ($cond === false) {
- $r = $this->_query['condition'];
- $_query['condition'] = '';
- $this->_query = $_query;
- return preg_replace('/^\s+WHERE\s+/','',$r);
- }
-
- if (!trim($cond)) {
- return $this->raiseError("WhereAdd: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
- $r = $_query['condition'];
- if ($_query['condition']) {
- $_query['condition'] .= " {$logic} ( {$cond} )";
- $this->_query = $_query;
- return $r;
- }
- $_query['condition'] = " WHERE ( {$cond} ) ";
- $this->_query = $_query;
- return $r;
- }
-
- function whereAddIn($key, $list, $type, $logic = 'AND')
- {
- $not = '';
- if ($key[0] == '!') {
- $not = 'NOT ';
- $key = substr($key, 1);
- }
-
- $type = $type == 'int' ? 'integer' : $type;
- if ($type == 'string') {
- $this->_connect();
- }
- $ar = array();
- foreach($list as $k) {
- settype($k, $type);
- $ar[] = $type == 'string' ? $this->_quote($k) : $k;
- }
-
- if (!$ar) {
- return $not ? $this->_query['condition'] : $this->whereAdd("1=0");
- }
- return $this->whereAdd("$key $not IN (". implode(',', $ar). ')', $logic );
- }
-
-
-
- function orderBy($order = false)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if ($order === false) {
- $this->_query['order_by'] = '';
- return;
- }
-
- if (!trim($order)) {
- return $this->raiseError("orderBy: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
-
- if (!$this->_query['order_by']) {
- $this->_query['order_by'] = " ORDER BY {$order} ";
- return;
- }
- $this->_query['order_by'] .= " , {$order}";
- }
-
- function groupBy($group = false)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if ($group === false) {
- $this->_query['group_by'] = '';
- return;
- }
-
- if (!trim($group)) {
- return $this->raiseError("groupBy: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
-
-
- if (!$this->_query['group_by']) {
- $this->_query['group_by'] = " GROUP BY {$group} ";
- return;
- }
- $this->_query['group_by'] .= " , {$group}";
- }
-
- function having($having = false)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if ($having === false) {
- $this->_query['having'] = '';
- return;
- }
-
- if (!trim($having)) {
- return $this->raiseError("Having: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
-
-
- if (!$this->_query['having']) {
- $this->_query['having'] = " HAVING {$having} ";
- return;
- }
- $this->_query['having'] .= " AND {$having}";
- }
-
- function useIndex($index = false)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if ($index=== false) {
- $this->_query['useindex'] = '';
- return;
- }
-
- if ((is_string($index) && !trim($index)) || (is_array($index) && !count($index)) ) {
- return $this->raiseError("Having: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
- $index = is_array($index) ? implode(', ', $index) : $index;
-
- if (!$this->_query['useindex']) {
- $this->_query['useindex'] = " USE INDEX ({$index}) ";
- return;
- }
- $this->_query['useindex'] = substr($this->_query['useindex'],0, -2) . ", {$index}) ";
- }
-
- function limit($a = null, $b = null)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
-
- if ($a === null) {
- $this->_query['limit_start'] = '';
- $this->_query['limit_count'] = '';
- return;
- }
-
- if ((!is_int($a) && ((string)((int)$a) !== (string)$a))
- || (($b !== null) && (!is_int($b) && ((string)((int)$b) !== (string)$b)))) {
- return $this->raiseError("limit: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
- global $_DB_DATAOBJECT;
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- $this->_query['limit_start'] = ($b == null) ? 0 : (int)$a;
- $this->_query['limit_count'] = ($b == null) ? (int)$a : (int)$b;
-
- }
-
- function selectAdd($k = null)
- {
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if ($k === null) {
- $old = $this->_query['data_select'];
- $this->_query['data_select'] = '';
- return $old;
- }
-
-
- if (!trim($k)) {
- return $this->raiseError("selectAdd: No Valid Arguments", DB_DATAOBJECT_ERROR_INVALIDARGS);
- }
-
- if ($this->_query['data_select']) {
- $this->_query['data_select'] .= ', ';
- }
- $this->_query['data_select'] .= " $k ";
- }
-
- function selectAs($from = null,$format = '%s',$tableName=false)
- {
- global $_DB_DATAOBJECT;
-
- if ($this->_query === false) {
- $this->raiseError(
- "You cannot do two queries on the same object (copy it before finding)",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
-
- if ($from === null) {
-
- $this->selectAdd();
- $from = $this;
- }
-
-
- $table = $this->tableName();
- if (is_object($from)) {
- $table = $from->tableName();
- $from = array_keys($from->table());
- }
-
- if ($tableName !== false) {
- $table = $tableName;
- }
- $s = '%s';
- if (!empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers'])) {
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- $s = $DB->quoteIdentifier($s);
- $format = $DB->quoteIdentifier($format);
- }
- foreach ($from as $k) {
- $this->selectAdd(sprintf("{$s}.{$s} as {$format}",$table,$k,$k));
- }
- $this->_query['data_select'] .= "\n";
- }
-
- function insert()
- {
- global $_DB_DATAOBJECT;
-
-
-
-
- if (!isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $this->_connect();
- }
-
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
-
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- $items = $this->table();
-
- if (!$items) {
- $this->raiseError("insert:No table definition for {$this->tableName()}",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- $options = $_DB_DATAOBJECT['CONFIG'];
- $datasaved = 1;
- $leftq = '';
- $rightq = '';
-
- $seqKeys = isset($_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()]) ?
- $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] :
- $this->sequenceKey();
-
- $key = isset($seqKeys[0]) ? $seqKeys[0] : false;
- $useNative = isset($seqKeys[1]) ? $seqKeys[1] : false;
- $seq = isset($seqKeys[2]) ? $seqKeys[2] : false;
-
- $dbtype = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn["phptype"];
-
-
-
-
-
- if (($key !== false) && !$useNative) {
-
- if (!$seq) {
- $keyvalue = $DB->nextId($this->tableName());
- } else {
- $f = $DB->getOption('seqname_format');
- $DB->setOption('seqname_format','%s');
- $keyvalue = $DB->nextId($seq);
- $DB->setOption('seqname_format',$f);
- }
- if (PEAR::isError($keyvalue)) {
- $this->raiseError($keyvalue->toString(), DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- $this->$key = $keyvalue;
- }
-
-
- $ignore_null = !isset($options['disable_null_strings'])
- || !is_string($options['disable_null_strings'])
- || strtolower($options['disable_null_strings']) !== 'full' ;
-
-
- foreach($items as $k => $v) {
-
-
- if ($key && ($k == $key) && $useNative) {
- continue;
- }
-
-
-
- if ( (!isset($this->$k) || ($v == 1 && $this->$k === ''))
- && $ignore_null
- ) {
- continue;
- }
-
-
- if ($v & DB_DATAOBJECT_MYSQLTIMESTAMP) {
- continue;
- }
-
- if ($leftq) {
- $leftq .= ', ';
- $rightq .= ', ';
- }
-
- $leftq .= ($quoteIdentifiers ? ($DB->quoteIdentifier($k) . ' ') : "$k ");
-
- if (is_object($this->$k) && is_a($this->$k,'DB_DataObject_Cast')) {
- $value = $this->$k->toString($v,$DB);
- if (PEAR::isError($value)) {
- $this->raiseError($value->toString() ,DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- $rightq .= $value;
- continue;
- }
-
-
- if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) {
- $rightq .= " NULL ";
- continue;
- }
-
-
- if (!$this->$k &&
- (($v & DB_DATAOBJECT_DATE) || ($v & DB_DATAOBJECT_TIME)) &&
- !($v & DB_DATAOBJECT_NOTNULL)) {
-
- $rightq .= " NULL ";
- continue;
- }
-
-
- if ($v & DB_DATAOBJECT_STR) {
- $rightq .= $this->_quote((string) (
- ($v & DB_DATAOBJECT_BOOL) ?
-
-
- (($this->$k === 'f') ? 0 : (int)(bool) $this->$k) :
- $this->$k
- )) . " ";
- continue;
- }
- if (is_numeric($this->$k)) {
- $rightq .=" {$this->$k} ";
- continue;
- }
-
- if (is_object($this->$k) || is_array($this->$k)) {
- $this->debug('ODD DATA: ' .$k . ' ' . print_r($this->$k,true),'ERROR');
- }
-
-
-
- $rightq .= ' ' . intval($this->$k) . ' ';
- }
-
-
-
-
- if ($leftq || $useNative) {
- $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this->tableName()) : $this->tableName());
-
-
- if (($dbtype == 'pgsql') && empty($leftq)) {
- $r = $this->_query("INSERT INTO {$table} DEFAULT VALUES");
- } else {
- $r = $this->_query("INSERT INTO {$table} ($leftq) VALUES ($rightq) ");
- }
-
-
-
-
- if (PEAR::isError($r)) {
- $this->raiseError($r);
- return false;
- }
-
- if ($r < 1) {
- return 0;
- }
-
-
-
-
- if ($key && $useNative) {
- switch ($dbtype) {
- case 'mysql':
- case 'mysqli':
- $method = "{$dbtype}_insert_id";
- $this->$key = $method(
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection
- );
- break;
-
- case 'mssql':
-
-
-
-
-
- $db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
- $method = ($db_driver == 'DB') ? 'getOne' : 'queryOne';
- $mssql_key = $DB->$method("SELECT @@IDENTITY");
- if (PEAR::isError($mssql_key)) {
- $this->raiseError($mssql_key);
- return false;
- }
- $this->$key = $mssql_key;
- break;
-
- case 'pgsql':
- if (!$seq) {
- $seq = $DB->getSequenceName(strtolower($this->tableName()));
- }
- $db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
- $method = ($db_driver == 'DB') ? 'getOne' : 'queryOne';
- $pgsql_key = $DB->$method("SELECT currval('".$seq . "')");
- if (PEAR::isError($pgsql_key)) {
- $this->raiseError($pgsql_key);
- return false;
- }
- $this->$key = $pgsql_key;
- break;
-
- case 'ifx':
- $this->$key = array_shift (
- ifx_fetch_row (
- ifx_query(
- "select DBINFO('sqlca.sqlerrd1') FROM systables where tabid=1",
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection,
- IFX_SCROLL
- ),
- "FIRST"
- )
- );
- break;
-
- }
-
- }
- if (isset($_DB_DATAOBJECT['CACHE'][strtolower(get_class($this))])) {
- $this->_clear_cache();
- }
- if ($key) {
- return $this->$key;
- }
- return true;
- }
- $this->raiseError("insert: No Data specifed for query", DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
-
- function update($dataObject = false)
- {
- global $_DB_DATAOBJECT;
-
- $this->_connect();
-
-
- $original_query = $this->_query;
-
- $items = $this->table();
-
-
-
- $seq = $this->sequenceKey();
- if ($seq[0] !== false) {
- $keys = array($seq[0]);
- if (!isset($this->{$keys[0]}) && $dataObject !== true) {
- $this->raiseError("update: trying to perform an update without
- the key set, and argument to update is not
- DB_DATAOBJECT_WHEREADD_ONLY
- ". print_r(array('seq' => $seq , 'keys'=>$keys), true), DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- } else {
- $keys = $this->keys();
- }
-
-
- if (!$items) {
- $this->raiseError("update:No table definition for {$this->tableName()}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- $datasaved = 1;
- $settings = '';
- $this->_connect();
-
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- $dbtype = $DB->dsn["phptype"];
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
- $options = $_DB_DATAOBJECT['CONFIG'];
-
-
- $ignore_null = !isset($options['disable_null_strings'])
- || !is_string($options['disable_null_strings'])
- || strtolower($options['disable_null_strings']) !== 'full' ;
-
-
- foreach($items as $k => $v) {
-
-
- if ((!isset($this->$k) || ($v == 1 && $this->$k === ''))
- && $ignore_null
- ) {
- continue;
- }
-
-
-
- if (($dataObject !== false) && isset($dataObject->$k) && ($dataObject->$k === $this->$k)) {
- continue;
- }
-
-
- if (in_array($k,$keys)) {
- continue;
- }
-
-
-
- if ($v & DB_DATAOBJECT_MYSQLTIMESTAMP) {
- continue;
- }
-
-
- if ($settings) {
- $settings .= ', ';
- }
-
- $kSql = ($quoteIdentifiers ? $DB->quoteIdentifier($k) : $k);
-
- if (is_object($this->$k) && is_a($this->$k,'DB_DataObject_Cast')) {
- $value = $this->$k->toString($v,$DB);
- if (PEAR::isError($value)) {
- $this->raiseError($value->getMessage() ,DB_DATAOBJECT_ERROR_INVALIDARG);
- return false;
- }
- $settings .= "$kSql = $value ";
- continue;
- }
-
-
- if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) {
- $settings .= "$kSql = NULL ";
- continue;
- }
-
-
- if (!$this->$k &&
- (($v & DB_DATAOBJECT_DATE) || ($v & DB_DATAOBJECT_TIME)) &&
- !($v & DB_DATAOBJECT_NOTNULL)) {
-
- $settings .= "$kSql = NULL ";
- continue;
- }
-
- if ($v & DB_DATAOBJECT_STR) {
- $settings .= "$kSql = ". $this->_quote((string) (
- ($v & DB_DATAOBJECT_BOOL) ?
-
-
- (($this->$k === 'f') ? 0 : (int)(bool) $this->$k) :
- $this->$k
- )) . ' ';
- continue;
- }
- if (is_numeric($this->$k)) {
- $settings .= "$kSql = {$this->$k} ";
- continue;
- }
-
-
- $settings .= "$kSql = " . intval($this->$k) . ' ';
- }
-
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("got keys as ".serialize($keys),3);
- }
- if ($dataObject !== true) {
- $this->_build_condition($items,$keys);
- } else {
-
- if (empty($this->_query['condition'])) {
- $this->raiseError("update: global table update not available
- do \$do->whereAdd('1=1'); if you really want to do that.
- ", DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- }
-
-
-
-
- if ($settings && isset($this->_query) && $this->_query['condition']) {
-
- $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this->tableName()) : $this->tableName());
-
- $r = $this->_query("UPDATE {$table} SET {$settings} {$this->_query['condition']} ");
-
-
- $this->_query = $original_query;
-
- if (PEAR::isError($r)) {
- $this->raiseError($r);
- return false;
- }
- if ($r < 1) {
- return 0;
- }
- $this->_clear_cache();
- return $r;
- }
-
- $this->_query = $original_query;
-
-
- if ($dataObject !== false) {
- return true;
- }
-
- $this->raiseError(
- "update: No Data specifed for query $settings , {$this->_query['condition']}",
- DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
-
- function delete($useWhere = false)
- {
- global $_DB_DATAOBJECT;
-
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
-
- $extra_cond = ' ' . (isset($this->_query['order_by']) ? $this->_query['order_by'] : '');
-
- if (!$useWhere) {
- $keys = $this->keys();
- $this->_query = array();
- $this->_query['condition'] = '';
- $this->_build_condition($this->table(),$keys);
-
- if (!$this->_query['condition']) {
- $this->_build_condition($this->table(),array(),$keys);
- }
- $extra_cond = '';
- }
-
-
- if (($this->_query !== false) && $this->_query['condition']) {
-
- $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this->tableName()) : $this->tableName());
- $sql = "DELETE ";
-
- $sql .= (!empty($this->_join) && $useWhere) ?
- "{$table} FROM {$table} {$this->_join} " :
- "FROM {$table} ";
-
- $sql .= $this->_query['condition']. $extra_cond;
-
-
-
- if (isset($this->_query['limit_start']) && strlen($this->_query['limit_start'] . $this->_query['limit_count'])) {
-
- if (!isset($_DB_DATAOBJECT['CONFIG']['db_driver']) ||
- ($_DB_DATAOBJECT['CONFIG']['db_driver'] == 'DB')) {
-
- $sql = $DB->modifyLimitQuery($sql,$this->_query['limit_start'], $this->_query['limit_count']);
-
- } else {
-
- $DB->setLimit( $this->_query['limit_count'],$this->_query['limit_start']);
- }
-
- }
-
-
- $r = $this->_query($sql);
-
-
- if (PEAR::isError($r)) {
- $this->raiseError($r);
- return false;
- }
- if ($r < 1) {
- return 0;
- }
- $this->_clear_cache();
- return $r;
- } else {
- $this->raiseError("delete: No condition specifed for query", DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
- }
-
- function fetchRow($row = null)
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- $this->_loadConfig();
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("{$this->tableName()} $row of {$this->N}", "fetchrow",3);
- }
- if (!$this->tableName()) {
- $this->raiseError("fetchrow: No table", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- if ($row === null) {
- $this->raiseError("fetchrow: No row specified", DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- if (!$this->N) {
- $this->raiseError("fetchrow: No results avaiable", DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("{$this->tableName()} $row of {$this->N}", "fetchrow",3);
- }
- $result = $_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid];
- $array = $result->fetchrow(DB_DATAOBJECT_FETCHMODE_ASSOC,$row);
- if (!is_array($array)) {
- $this->raiseError("fetchrow: No results available", DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
- $replace = array('.', ' ');
- foreach($array as $k => $v) {
-
- $kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
- $k : str_replace($replace, '_', $k);
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("$kk = ". $array[$k], "fetchrow LINE", 3);
- }
- $this->$kk = $array[$k];
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("{$this->tableName()} DONE", "fetchrow", 3);
- }
- return true;
- }
-
- function count($countWhat = false,$whereAddOnly = false)
- {
- global $_DB_DATAOBJECT;
-
- if (is_bool($countWhat)) {
- $whereAddOnly = $countWhat;
- }
-
- $t = clone($this);
- $items = $t->table();
-
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
-
-
- if (!isset($t->_query)) {
- $this->raiseError(
- "You cannot do run count after you have run fetch()",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- if (!$whereAddOnly && $items) {
- $t->_build_condition($items);
- }
- $keys = $this->keys();
- if (empty($keys[0]) && (!is_string($countWhat) || (strtoupper($countWhat) == 'DISTINCT'))) {
- $this->raiseError(
- "You cannot do run count without keys - use \$do->count('id'), or use \$do->count('distinct id')';",
- DB_DATAOBJECT_ERROR_INVALIDARGS,PEAR_ERROR_DIE);
- return false;
-
- }
- $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this->tableName()) : $this->tableName());
- $key_col = empty($keys[0]) ? '' : (($quoteIdentifiers ? $DB->quoteIdentifier($keys[0]) : $keys[0]));
- $as = ($quoteIdentifiers ? $DB->quoteIdentifier('DATAOBJECT_NUM') : 'DATAOBJECT_NUM');
-
-
- $countWhat = (strtoupper($countWhat) == 'DISTINCT') ?
- "DISTINCT {$table}.{$key_col}" : $countWhat;
-
- $countWhat = is_string($countWhat) ? $countWhat : "{$table}.{$key_col}";
-
- $r = $t->_query(
- "SELECT count({$countWhat}) as $as
- FROM $table {$t->_join} {$t->_query['condition']}");
- if (PEAR::isError($r)) {
- return false;
- }
-
- $result = $_DB_DATAOBJECT['RESULTS'][$t->_DB_resultid];
- $l = $result->fetchRow(DB_DATAOBJECT_FETCHMODE_ORDERED);
-
- $t->free();
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug('Count returned '. $l[0] ,1);
- }
- return (int) $l[0];
- }
-
- function query($string)
- {
- return $this->_query($string);
- }
-
- function escape($string, $likeEscape=false)
- {
- global $_DB_DATAOBJECT;
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- $dd = empty($_DB_DATAOBJECT['CONFIG']['db_driver']) ? 'DB' : $_DB_DATAOBJECT['CONFIG']['db_driver'];
- $ret = ($dd == 'DB') ? $DB->escapeSimple($string) : $DB->escape($string);
- if ($likeEscape) {
- $ret = str_replace(array('_','%'), array('\_','\%'), $ret);
- }
- return $ret;
-
- }
-
-
-
-
- var $_database_dsn = '';
-
- var $_database_dsn_md5 = '';
-
- var $_database = '';
-
-
-
- var $_query = array(
- 'condition' => '',
- 'group_by' => '',
- 'order_by' => '',
- 'having' => '',
- 'useindex' => '',
- 'limit_start' => '',
- 'limit_count' => '',
- 'data_select' => '*',
- 'unions' => array(),
- 'derive_table' => '',
- 'derive_select' => '',
- );
-
-
-
-
- var $_DB_resultid;
-
-
- var $_resultFields = false;
-
-
-
-
- function databaseStructure()
- {
- global $_DB_DATAOBJECT;
-
-
-
- if ($args = func_get_args()) {
-
- if (count($args) == 1) {
-
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("Loading Generator as databaseStructure called with args",1);
- }
-
- $x = new DB_DataObject;
- $x->_database = $args[0];
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- $tables = $DB->getListOf('tables');
- class_exists('DB_DataObject_Generator') ? '' :
- require_once 'DB/DataObject/Generator.php';
-
- foreach($tables as $table) {
- $y = new DB_DataObject_Generator;
- $y->fillTableSchema($x->_database,$table);
- }
- return $_DB_DATAOBJECT['INI'][$x->_database];
- } else {
-
- $_DB_DATAOBJECT['INI'][$args[0]] = isset($_DB_DATAOBJECT['INI'][$args[0]]) ?
- $_DB_DATAOBJECT['INI'][$args[0]] + $args[1] : $args[1];
-
- if (isset($args[1])) {
- $_DB_DATAOBJECT['LINKS'][$args[0]] = isset($_DB_DATAOBJECT['LINKS'][$args[0]]) ?
- $_DB_DATAOBJECT['LINKS'][$args[0]] + $args[2] : $args[2];
- }
- return true;
- }
-
- }
-
-
-
- if (!$this->_database) {
- $this->_connect();
- }
-
-
-
- if (!empty($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()])) {
- return true;
- }
-
-
- if (empty($_DB_DATAOBJECT['INI'][$this->_database])) {
- $_DB_DATAOBJECT['INI'][$this->_database] = array();
- }
-
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
-
-
-
-
-
- if ( !empty($_DB_DATAOBJECT['CONFIG']['proxy']) ) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("Loading Generator to fetch Schema",1);
- }
- class_exists('DB_DataObject_Generator') ? '' :
- require_once 'DB/DataObject/Generator.php';
-
-
- $x = new DB_DataObject_Generator;
- $x->fillTableSchema($this->_database,$this->tableName());
- return true;
- }
-
-
-
-
-
-
-
- $schemas = isset($_DB_DATAOBJECT['CONFIG']['schema_location']) ?
- array("{$_DB_DATAOBJECT['CONFIG']['schema_location']}/{$this->_database}.ini") :
- array() ;
-
- if (isset($_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"])) {
- $schemas = is_array($_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"]) ?
- $_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"] :
- explode(PATH_SEPARATOR,$_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"]);
- }
-
-
- $_DB_DATAOBJECT['INI'][$this->_database] = array();
- foreach ($schemas as $ini) {
- if (file_exists($ini) && is_file($ini)) {
-
- $_DB_DATAOBJECT['INI'][$this->_database] = array_merge(
- $_DB_DATAOBJECT['INI'][$this->_database],
- parse_ini_file($ini, true)
- );
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- if (!is_readable ($ini)) {
- $this->debug("ini file is not readable: $ini","databaseStructure",1);
- } else {
- $this->debug("Loaded ini file: $ini","databaseStructure",1);
- }
- }
- } else {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("Missing ini file: $ini","databaseStructure",1);
- }
- }
-
- }
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['portability']) && $_DB_DATAOBJECT['CONFIG']['portability'] & 1) {
- foreach($_DB_DATAOBJECT['INI'][$this->_database] as $k=>$v) {
-
- $_DB_DATAOBJECT['INI'][$this->_database][strtolower($k)] = $v;
- }
- }
-
-
-
-
- if (!empty($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()])) {
- return true;
- }
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['proxy'])) {
- class_exists('DB_DataObject_Generator') ? '' :
- require_once 'DB/DataObject/Generator.php';
-
- $x = new DB_DataObject_Generator;
- $x->fillTableSchema($this->_database,$this->tableName());
-
- return true;
- }
- $this->debug("Cant find database schema: {$this->_database}/{$this->tableName()} \n".
- "in links file data: " . print_r($_DB_DATAOBJECT['INI'],true),"databaseStructure",5);
-
- $this->raiseError( "Unable to load schema for database and table (turn debugging up to 5 for full error message)", DB_DATAOBJECT_ERROR_INVALIDARGS, PEAR_ERROR_DIE);
- return false;
-
-
- }
-
- function tableName()
- {
- global $_DB_DATAOBJECT;
- $args = func_get_args();
- if (count($args)) {
- $this->__table = $args[0];
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['portability']) && $_DB_DATAOBJECT['CONFIG']['portability'] & 1) {
- return strtolower($this->__table);
- }
- return $this->__table;
- }
-
-
- function database()
- {
- $args = func_get_args();
- if (count($args)) {
- $this->_database = $args[0];
- } else {
- $this->_connect();
- }
-
- return $this->_database;
- }
-
-
- function table()
- {
-
-
-
- $args = func_get_args();
- if (count($args)) {
- $this->_database_fields = $args[0];
- }
- if (isset($this->_database_fields)) {
- return $this->_database_fields;
- }
-
-
- global $_DB_DATAOBJECT;
- if (!isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $this->_connect();
- }
-
- if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()])) {
- return $_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()];
- }
-
- $this->databaseStructure();
-
-
- $ret = array();
- if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()])) {
- $ret = $_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()];
- }
-
- return $ret;
- }
-
- function keys()
- {
-
-
- $args = func_get_args();
- if (count($args)) {
- $this->_database_keys = $args;
- }
- if (isset($this->_database_keys)) {
- return $this->_database_keys;
- }
-
- global $_DB_DATAOBJECT;
- if (!isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $this->_connect();
- }
- if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"])) {
- return array_keys($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"]);
- }
- $this->databaseStructure();
-
- if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"])) {
- return array_keys($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"]);
- }
- return array();
- }
-
- function sequenceKey()
- {
- global $_DB_DATAOBJECT;
-
-
- if (!$this->_database) {
- $this->_connect();
- }
-
- if (!isset($_DB_DATAOBJECT['SEQUENCE'][$this->_database])) {
- $_DB_DATAOBJECT['SEQUENCE'][$this->_database] = array();
- }
-
- $args = func_get_args();
- if (count($args)) {
- $args[1] = isset($args[1]) ? $args[1] : false;
- $args[2] = isset($args[2]) ? $args[2] : false;
- $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = $args;
- }
- if (isset($_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()])) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()];
- }
-
-
-
-
-
- $keys = $this->keys();
- if (!$keys) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()]
- = array(false,false,false);
- }
-
- $table = $this->table();
-
- $dbtype = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'];
-
- $usekey = $keys[0];
-
-
-
- $seqname = false;
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['sequence_'.$this->tableName()])) {
- $seqname = $_DB_DATAOBJECT['CONFIG']['sequence_'.$this->tableName()];
- if (strpos($seqname,':') !== false) {
- list($usekey,$seqname) = explode(':',$seqname);
- }
- }
-
-
-
- if (empty($table[$usekey]) || !($table[$usekey] & DB_DATAOBJECT_INT)) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array(false,false,false);
- }
-
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'])) {
- $ignore = $_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'];
- if (is_string($ignore) && (strtoupper($ignore) == 'ALL')) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array(false,false,$seqname);
- }
- if (is_string($ignore)) {
- $ignore = $_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'] = explode(',',$ignore);
- }
- if (in_array($this->tableName(),$ignore)) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array(false,false,$seqname);
- }
- }
-
-
- $realkeys = $_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"];
-
-
- if (is_numeric($realkeys[$usekey])) {
- $realkeys[$usekey] = 'N';
- }
-
-
- if (($realkeys[$usekey] == 'K') && (count($keys) > 1)) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array(false,false,$seqname);
- }
-
-
-
-
-
-
- if ( in_array($dbtype , array('pgsql')) &&
- ($table[$usekey] & DB_DATAOBJECT_INT) &&
- isset($realkeys[$usekey]) && strlen($realkeys[$usekey]) > 1) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array($usekey,true, $realkeys[$usekey]);
- }
-
- if ( in_array($dbtype , array('pgsql', 'mysql', 'mysqli', 'mssql', 'ifx')) &&
- ($table[$usekey] & DB_DATAOBJECT_INT) &&
- isset($realkeys[$usekey]) && ($realkeys[$usekey] == 'N')
- ) {
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array($usekey,true,$seqname);
- }
-
-
-
- if (($realkeys[$usekey] != 'N') &&
- !empty($_DB_DATAOBJECT['CONFIG']['dont_use_pear_sequences'])) {
- return array(false,false,false);
- }
-
-
-
-
- return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->tableName()] = array($usekey,false,$seqname);
- }
-
-
-
-
-
-
-
-
-
- function _clear_cache()
- {
- global $_DB_DATAOBJECT;
-
- $class = strtolower(get_class($this));
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("Clearing Cache for ".$class,1);
- }
-
- if (!empty($_DB_DATAOBJECT['CACHE'][$class])) {
- unset($_DB_DATAOBJECT['CACHE'][$class]);
- }
- }
-
-
-
- function _quote($str)
- {
- global $_DB_DATAOBJECT;
- return (empty($_DB_DATAOBJECT['CONFIG']['db_driver']) ||
- ($_DB_DATAOBJECT['CONFIG']['db_driver'] == 'DB'))
- ? $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->quoteSmart($str)
- : $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->quote($str);
- }
-
-
-
- function _connect()
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- $this->_loadConfig();
- }
-
- $db_driver = empty($_DB_DATAOBJECT['CONFIG']['db_driver']) ?
- 'DB' : $_DB_DATAOBJECT['CONFIG']['db_driver'];
-
-
- if ($this->_database_dsn_md5 && !empty($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
-
-
- if (PEAR::isError($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- return $this->raiseError(
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->message,
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->code, PEAR_ERROR_DIE
- );
-
- }
- if (empty($this->_database)) {
- $this->_database = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['database'];
- $hasGetDatabase = method_exists($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5], 'getDatabase');
-
- $this->_database = ($db_driver != 'DB' && $hasGetDatabase)
- ? $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->getDatabase()
- : $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['database'];
-
-
- if (($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'] == 'sqlite')
- && is_file($this->_database)) {
- $this->_database = basename($this->_database);
- }
- if ($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'] == 'ibase') {
- $this->_database = substr(basename($this->_database), 0, -4);
- }
-
- }
-
-
- return true;
-
- }
-
-
- $options= $_DB_DATAOBJECT['CONFIG'];
-
- $dsn = isset($this->_database_dsn) ? $this->_database_dsn : null;
-
- if (!$dsn) {
- if (!$this->_database && !empty($this->__table)) {
- $this->_database = isset($options["table_{$this->tableName()}"]) ? $options["table_{$this->tableName()}"] : null;
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("Checking for database specific ini ('{$this->_database}') : database_{$this->_database} in options","CONNECT");
- }
-
- if ($this->_database && !empty($options["database_{$this->_database}"])) {
- $dsn = $options["database_{$this->_database}"];
- } else if (!empty($options['database'])) {
- $dsn = $options['database'];
-
- }
- }
-
-
- if (!$dsn) {
- return $this->raiseError(
- "No database name / dsn found anywhere",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG, PEAR_ERROR_DIE
- );
-
- }
-
-
- if (is_string($dsn)) {
- $this->_database_dsn_md5 = md5($dsn);
- } else {
-
- $this->_database_dsn_md5 = md5(serialize($dsn));
- }
- if (!empty($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("USING CACHED CONNECTION", "CONNECT",3);
- }
-
-
-
- if (!$this->_database) {
- $hasGetDatabase = method_exists($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5], 'getDatabase');
- $this->_database = ($db_driver != 'DB' && $hasGetDatabase)
- ? $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->getDatabase()
- : $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['database'];
-
- if (($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'] == 'sqlite')
- && is_file($this->_database))
- {
- $this->_database = basename($this->_database);
- }
- }
- return true;
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug("NEW CONNECTION TP DATABASE :" .$this->_database , "CONNECT",3);
-
- $this->debug(print_r($dsn,true) ." {$this->_database_dsn_md5}", "CONNECT",3);
- }
-
-
-
- if ($db_driver == 'DB') {
-
-
-
-
- $db_options = PEAR::getStaticProperty('DB','options');
- require_once 'DB.php';
- if ($db_options) {
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = DB::connect($dsn,$db_options);
- } else {
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = DB::connect($dsn);
- }
-
- } else {
-
- require_once 'MDB2.php';
-
- $db_options = PEAR::getStaticProperty('MDB2','options');
- $db_options = is_array($db_options) ? $db_options : array();
- $db_options['portability'] = isset($db_options['portability'] )
- ? $db_options['portability'] : MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_FIX_CASE;
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = MDB2::connect($dsn,$db_options);
-
- }
-
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug(print_r($_DB_DATAOBJECT['CONNECTIONS'],true), "CONNECT",5);
- }
- if (PEAR::isError($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $this->debug($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->toString(), "CONNECT FAILED",5);
- return $this->raiseError(
- "Connect failed, turn on debugging to 5 see why",
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->code, PEAR_ERROR_DIE
- );
- }
-
- if (empty($this->_database)) {
- $hasGetDatabase = method_exists($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5], 'getDatabase');
-
- $this->_database = ($db_driver != 'DB' && $hasGetDatabase)
- ? $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->getDatabase()
- : $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['database'];
- if (($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'] == 'sqlite')
- && is_file($this->_database))
- {
- $this->_database = basename($this->_database);
- }
- }
-
-
-
- return true;
- }
-
- function _query($string)
- {
- global $_DB_DATAOBJECT;
- $this->_connect();
-
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- $options = $_DB_DATAOBJECT['CONFIG'];
-
- $_DB_driver = empty($_DB_DATAOBJECT['CONFIG']['db_driver']) ?
- 'DB': $_DB_DATAOBJECT['CONFIG']['db_driver'];
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug($string,$log="QUERY");
-
- }
-
- if (
- strtoupper($string) == 'BEGIN' ||
- strtoupper($string) == 'START TRANSACTION'
- ) {
- if ($_DB_driver == 'DB') {
- $DB->autoCommit(false);
- $DB->simpleQuery('BEGIN');
- } else {
- $DB->beginTransaction();
- }
- return true;
- }
-
- if (strtoupper($string) == 'COMMIT') {
- $res = $DB->commit();
- if ($_DB_driver == 'DB') {
- $DB->autoCommit(true);
- }
- return $res;
- }
-
- if (strtoupper($string) == 'ROLLBACK') {
- $DB->rollback();
- if ($_DB_driver == 'DB') {
- $DB->autoCommit(true);
- }
- return true;
- }
-
- if (!empty($options['debug_ignore_updates']) &&
- (strtolower(substr(trim($string), 0, 6)) != 'select') &&
- (strtolower(substr(trim($string), 0, 4)) != 'show') &&
- (strtolower(substr(trim($string), 0, 8)) != 'describe')) {
- $this->debug('Disabling Update as you are in debug mode');
- return $this->raiseError("Disabling Update as you are in debug mode", null) ;
- }
-
-
-
-
-
-
- $t= explode(' ',microtime());
- $_DB_DATAOBJECT['QUERYENDTIME'] = $time = $t[0]+$t[1];
-
-
- for ($tries = 0;$tries < 3;$tries++) {
-
- if ($_DB_driver == 'DB') {
-
- $result = $DB->query($string);
- } else {
- switch (strtolower(substr(trim($string),0,6))) {
-
- case 'insert':
- case 'update':
- case 'delete':
- $result = $DB->exec($string);
- break;
-
- default:
- $result = $DB->query($string);
- break;
- }
- }
-
-
- if (!is_object($result) || !is_a($result,'PEAR_Error')) {
- break;
- }
- if ($result->getCode() != -14) {
- break;
- }
- sleep(1);
- $DB->connect($DB->dsn);
- }
-
- if (is_object($result) && is_a($result,'PEAR_Error')) {
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug($result->toString(), "Query Error",1 );
- }
- $this->N = false;
- return $this->raiseError($result);
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $t= explode(' ',microtime());
- $_DB_DATAOBJECT['QUERYENDTIME'] = $t[0]+$t[1];
- $this->debug('QUERY DONE IN '.($t[0]+$t[1]-$time)." seconds", 'query',1);
- }
- switch (strtolower(substr(trim($string),0,6))) {
- case 'insert':
- case 'update':
- case 'delete':
- if ($_DB_driver == 'DB') {
-
- return $DB->affectedRows();
- }
- return $result;
- }
- if (is_object($result)) {
-
-
- $_DB_resultid = $GLOBALS['_DB_DATAOBJECT']['RESULTSEQ']++;
- $_DB_DATAOBJECT['RESULTS'][$_DB_resultid] = $result;
- $this->_DB_resultid = $_DB_resultid;
- }
- $this->N = 0;
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- $this->debug(serialize($result), 'RESULT',5);
- }
- if (method_exists($result, 'numRows')) {
- if ($_DB_driver == 'DB') {
- $DB->expectError(DB_ERROR_UNSUPPORTED);
- } else {
- $DB->expectError(MDB2_ERROR_UNSUPPORTED);
- }
-
- $this->N = $result->numRows();
-
-
- if (is_object($this->N) && is_a($this->N,'PEAR_Error')) {
- $this->N = true;
- }
- $DB->popExpect();
- }
- }
-
- function _build_condition($keys, $filter = array(),$negative_filter=array())
- {
- global $_DB_DATAOBJECT;
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
- $options = $_DB_DATAOBJECT['CONFIG'];
-
-
- if ($this->_query === false) {
- $x = new DB_DataObject;
- $this->_query= $x->_query;
- }
-
-
- foreach($keys as $k => $v) {
-
-
- if ($filter) {
- if (!in_array($k, $filter)) {
- continue;
- }
- }
- if ($negative_filter) {
- if (in_array($k, $negative_filter)) {
- continue;
- }
- }
- if (!isset($this->$k)) {
- continue;
- }
-
- $kSql = $quoteIdentifiers
- ? ( $DB->quoteIdentifier($this->tableName()) . '.' . $DB->quoteIdentifier($k) )
- : "{$this->tableName()}.{$k}";
-
-
-
- if (is_object($this->$k) && is_a($this->$k,'DB_DataObject_Cast')) {
- $dbtype = $DB->dsn["phptype"];
- $value = $this->$k->toString($v,$DB);
- if (PEAR::isError($value)) {
- $this->raiseError($value->getMessage() ,DB_DATAOBJECT_ERROR_INVALIDARG);
- return false;
- }
- if ((strtolower($value) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) {
- $this->whereAdd(" $kSql IS NULL");
- continue;
- }
- $this->whereAdd(" $kSql = $value");
- continue;
- }
-
- if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this,$k)) {
- $this->whereAdd(" $kSql IS NULL");
- continue;
- }
-
- if ($v & DB_DATAOBJECT_STR) {
- $this->whereAdd(" $kSql = " . $this->_quote((string) (
- ($v & DB_DATAOBJECT_BOOL) ?
-
-
- (($this->$k === 'f') ? 0 : (int)(bool) $this->$k) :
- $this->$k
- )) );
- continue;
- }
- if (is_numeric($this->$k)) {
- $this->whereAdd(" $kSql = {$this->$k}");
- continue;
- }
-
- $this->whereAdd(" $kSql = ".intval($this->$k));
- }
- }
-
-
-
-
-
- static function factory($table = '')
- {
- global $_DB_DATAOBJECT;
-
-
-
- $database = '';
-
- if (strpos( $table,'/') !== false ) {
- list($database,$table) = explode('.',$table, 2);
-
- }
-
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
-
- if (!empty($database) && empty($_DB_DATAOBJECT['CONFIG']['database_'.$database])) {
- $do = new DB_DataObject();
- $do->raiseError(
- "unable to find database_{$database} in Configuration, It is required for factory with database"
- , 0, PEAR_ERROR_DIE );
- }
-
-
-
-
- $cp = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ?
- explode(PATH_SEPARATOR, $_DB_DATAOBJECT['CONFIG']['class_prefix']) : '';
-
-
-
-
- $tbl = preg_replace('/[^A-Z0-9]/i','_',ucfirst($table));
- if (is_array($cp)) {
- $class = array();
- foreach($cp as $cpr) {
- $ce = substr(phpversion(),0,1) > 4 ? class_exists($cpr . $tbl,false) : class_exists($cpr . $tbl);
- if ($ce) {
- $class = $cpr . $tbl;
- break;
- }
- $class[] = $cpr . $tbl;
- }
- } else {
- $class = $tbl;
- $ce = substr(phpversion(),0,1) > 4 ? class_exists($class,false) : class_exists($class);
- }
-
-
- $rclass = $ce ? $class : DB_DataObject::_autoloadClass($class, $table);
-
- if (!$rclass && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) {
-
- DB_DataObject::debug("FAILED TO Autoload $database.$table - using proxy.","FACTORY",1);
-
-
- $proxyMethod = 'getProxy'.$_DB_DATAOBJECT['CONFIG']['proxy'];
-
- class_exists('DB_DataObject_Generator') ? '' :
- require_once 'DB/DataObject/Generator.php';
-
- $d = new DB_DataObject;
-
- $d->__table = $table;
-
- $ret = $d->_connect();
- if (is_object($ret) && is_a($ret, 'PEAR_Error')) {
- return $ret;
- }
-
- $x = new DB_DataObject_Generator;
- return $x->$proxyMethod( $d->_database, $table);
- }
-
- if (!$rclass || !class_exists($rclass)) {
- $dor = new DB_DataObject();
- return $dor->raiseError(
- "factory could not find class " .
- (is_array($class) ? implode(PATH_SEPARATOR, $class) : $class ).
- "from $table",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- }
-
- $ret = new $rclass();
-
- if (!empty($database)) {
- DB_DataObject::debug("Setting database to $database","FACTORY",1);
- $ret->database($database);
- }
- return $ret;
- }
-
- function _autoloadClass($class, $table=false)
- {
- global $_DB_DATAOBJECT;
-
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- $class_prefix = empty($_DB_DATAOBJECT['CONFIG']['class_prefix']) ?
- '' : $_DB_DATAOBJECT['CONFIG']['class_prefix'];
-
- $table = $table ? $table : substr($class,strlen($class_prefix));
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['proxy']) || empty($_DB_DATAOBJECT['CONFIG']['class_location'])) {
- return false;
- }
-
-
-
-
-
- $cl = $_DB_DATAOBJECT['CONFIG']['class_location'];
-
-
- switch (true) {
- case (strpos($cl ,'%s') !== false):
- $file = sprintf($cl , preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)));
- break;
-
- case (strpos($cl , PATH_SEPARATOR) !== false):
- $file = array();
- foreach(explode(PATH_SEPARATOR, $cl ) as $p) {
- $file[] = $p .'/'.preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)).".php";
- }
- break;
- default:
- $file = $cl .'/'.preg_replace('/[^A-Z0-9]/i','_',ucfirst($table)).".php";
- break;
- }
-
- $cls = is_array($class) ? $class : array($class);
-
- if (is_array($file) || !file_exists($file)) {
- $found = false;
-
- $file = is_array($file) ? $file : array($file);
- $search = implode(PATH_SEPARATOR, $file);
- foreach($file as $f) {
- foreach(explode(PATH_SEPARATOR, '' . PATH_SEPARATOR . ini_get('include_path')) as $p) {
- $ff = empty($p) ? $f : "$p/$f";
- if (file_exists($ff)) {
- $file = $ff;
- $found = true;
- break;
- }
- }
- if ($found) {
- break;
- }
- }
- if (!$found) {
- $dor = new DB_DataObject();
- $dor->raiseError(
- "autoload:Could not find class " . implode(',', $cls) .
- " using class_location value :" . $search .
- " using include_path value :" . ini_get('include_path'),
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- }
-
- include_once $file;
-
-
- $ce = false;
- foreach($cls as $c) {
- $ce = substr(phpversion(),0,1) > 4 ? class_exists($c,false) : class_exists($c);
- if ($ce) {
- $class = $c;
- break;
- }
- }
- if (!$ce) {
- $dor = new DB_DataObject();
- $dor->raiseError(
- "autoload:Could not autoload " . implode(',', $cls) ,
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
- return $class;
- }
-
-
-
-
- var $_link_loaded = false;
-
-
-
- function links()
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- $this->_loadConfig();
- }
-
- $this->_connect();
-
-
- $lcfg = &$_DB_DATAOBJECT['LINKS'];
- $cfg = $_DB_DATAOBJECT['CONFIG'];
- if ($args = func_get_args()) {
-
-
- if (empty( $lcfg[$this->_database])) {
- $lcfg[$this->_database] = array();
- }
- $lcfg[$this->_database][$this->tableName()] = $args[0];
-
- }
-
- if (isset($lcfg[$this->_database][$this->tableName()])) {
- return $lcfg[$this->_database][$this->tableName()];
- }
-
- if (isset($lcfg[$this->_database])) {
-
- return $lcfg[$this->_database] === false ? null : array();
- }
-
-
- $schemas = isset($cfg['schema_location']) ?
- array("{$cfg['schema_location']}/{$this->_database}.ini") :
- array() ;
-
-
- if (isset($cfg["ini_{$this->_database}"])) {
- $schemas = is_array($cfg["ini_{$this->_database}"]) ?
- $cfg["ini_{$this->_database}"] :
- explode(PATH_SEPARATOR,$cfg["ini_{$this->_database}"]);
- }
-
-
- $lcfg[$this->_database] = false;
- foreach ($schemas as $ini) {
-
- $links = isset($cfg["links_{$this->_database}"]) ?
- $cfg["links_{$this->_database}"] :
- str_replace('.ini','.links.ini',$ini);
-
-
- if (!file_exists($links) || !is_file($links)) {
- if (!empty($cfg['debug'])) {
- $this->debug("Missing links.ini file: $links","links",1);
- }
- continue;
- }
-
- $lcfg[$this->_database] = empty($lcfg[$this->_database]) ? array() : $lcfg[$this->_database];
-
- $lcfg[$this->_database] = array_merge(
- $lcfg[$this->_database],
- parse_ini_file($links, true)
- );
-
- if (!empty($cfg['debug'])) {
- $this->debug("Loaded links.ini file: $links","links",1);
- }
-
- }
-
- if (!empty($_DB_DATAOBJECT['CONFIG']['portability']) && $_DB_DATAOBJECT['CONFIG']['portability'] & 1) {
- foreach($lcfg[$this->_database] as $k=>$v) {
-
- $nk = strtolower($k);
-
- $lcfg[$this->_database][$nk] = isset($lcfg[$this->_database][$nk])
- ? $lcfg[$this->_database][$nk] : array();
-
- foreach($v as $kk =>$vv) {
-
- $vv =explode(':', $vv);
- $vv[0] = strtolower($vv[0]);
- $lcfg[$this->_database][$nk][$kk] = implode(':', $vv);
- }
-
-
- }
- }
-
-
-
-
- if ($lcfg[$this->_database] === false) {
- return null;
- }
-
- if (isset($lcfg[$this->_database][$this->tableName()])) {
- return $lcfg[$this->_database][$this->tableName()];
- }
-
- return array();
- }
-
-
-
- function link($field, $set_args = array())
- {
- require_once 'DB/DataObject/Links.php';
- $l = new DB_DataObject_Links($this);
- return $l->link($field,$set_args) ;
-
- }
-
-
- function getLinks($format = '_%s')
- {
- require_once 'DB/DataObject/Links.php';
- $l = new DB_DataObject_Links($this);
- return $l->applyLinks($format);
-
- }
-
- function getLink($row, $table = null, $link = false)
- {
- require_once 'DB/DataObject/Links.php';
- $l = new DB_DataObject_Links($this);
- return $l->getLink($row, $table === null ? false: $table, $link);
-
-
- }
-
- function getLinkArray($row, $table = null)
- {
- require_once 'DB/DataObject/Links.php';
- $l = new DB_DataObject_Links($this);
- return $l->getLinkArray($row, $table === null ? false: $table);
-
- }
-
-
- function unionAdd($obj,$is_all= '')
- {
- if ($obj === false) {
- $ret = $this->_query['unions'];
- $this->_query['unions'] = array();
- return $ret;
- }
- $this->_query['unions'][] = array($obj, 'UNION ' . $is_all . ' ') ;
- return $obj;
- }
-
-
-
- var $_join = '';
-
- function joinAdd($obj = false, $joinType='INNER', $joinAs=false, $joinCol=false)
- {
- global $_DB_DATAOBJECT;
- if ($obj === false) {
- $this->_join = '';
- return;
- }
-
-
- $useWhereAsOn = false;
-
- if (is_array($joinType)) {
-
- $useWhereAsOn = !empty($joinType['useWhereAsOn']);
- $joinCol = isset($joinType['joinCol']) ? $joinType['joinCol'] : $joinCol;
- $joinAs = isset($joinType['joinAs']) ? $joinType['joinAs'] : $joinAs;
- $joinType = isset($joinType['joinType']) ? $joinType['joinType'] : 'INNER';
- }
-
-
-
-
- $ofield = false;
- $tfield = false;
- $toTable = false;
- if (is_array($obj)) {
- $tfield = $obj[0];
-
- if (count($obj) == 3) {
- $ofield = $obj[2];
- $obj = $obj[1];
- } else {
- list($toTable,$ofield) = explode(':',$obj[1]);
-
- $obj = is_string($toTable) ? DB_DataObject::factory($toTable) : $toTable;
-
- if (!$obj || !is_object($obj) || is_a($obj,'PEAR_Error')) {
- $obj = new DB_DataObject;
- $obj->__table = $toTable;
- }
- $obj->_connect();
- }
-
-
- $items = array();
- }
-
- if (!is_object($obj) || !is_a($obj,'DB_DataObject')) {
- return $this->raiseError("joinAdd: called without an object", DB_DATAOBJECT_ERROR_NODATA,PEAR_ERROR_DIE);
- }
-
- $this->_connect();
- $DB = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
-
-
-
-
-
- if (($ofield === false) && ($links = $this->links())) {
-
-
-
-
- foreach ($links as $k => $linkVar) {
-
- if (!is_array($linkVar)) {
- $linkVar = array($linkVar);
- }
- foreach($linkVar as $v) {
-
-
-
- $ar = explode(':', $v);
-
- if (strpos($k, ',') !== false) {
- $k = explode(',', $k);
- }
- if (strpos($ar[1], ',') !== false) {
- $ar[1] = explode(',', $ar[1]);
- }
- if ($ar[0] != $obj->tableName()) {
- continue;
- }
- if ($joinCol !== false) {
- if ($k == $joinCol) {
-
- $tfield = $k;
- $ofield = $ar[1];
- break;
- }
- continue;
-
- }
- $tfield = $k;
- $ofield = $ar[1];
- break;
-
- }
- }
- }
-
-
- if (!$ofield && ($olinks = $obj->links())) {
-
- foreach ($olinks as $k => $linkVar) {
-
- if (!is_array($linkVar)) {
- $linkVar = array($linkVar);
- }
- foreach($linkVar as $v) {
-
-
- $ar = explode(':', $v);
-
-
- $links_key_array = strpos($k,',');
- if ($links_key_array !== false) {
- $k = explode(',', $k);
- }
-
- $ar_array = strpos($ar[1],',');
- if ($ar_array !== false) {
- $ar[1] = explode(',', $ar[1]);
- }
-
- if ($ar[0] != $this->tableName()) {
- continue;
- }
-
-
-
-
-
- if ($joinCol !== false) {
- $this->raiseError(
- "joinAdd: You cannot target a join column in the " .
- "'link from' table ({$obj->__table}). " .
- "Either remove the fourth argument to joinAdd() ".
- "({$joinCol}), or alter your links.ini file.",
- DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
-
- $ofield = $k;
- $tfield = $ar[1];
- break;
-
- }
- }
- }
-
- if (($ofield === false) && $joinCol) {
- $ofield = $joinCol;
- $tfield = $joinCol;
- }
-
- if ($ofield === false) {
- $this->raiseError(
- "joinAdd: {$obj->tableName()} has no link with {$this->tableName()}",
- DB_DATAOBJECT_ERROR_NODATA);
- return false;
- }
- $joinType = strtoupper($joinType);
-
-
-
- if ($joinAs === false) {
- $joinAs = $obj->tableName();
- }
-
- $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
- $options = $_DB_DATAOBJECT['CONFIG'];
-
-
- $objTable = $quoteIdentifiers ?
- $DB->quoteIdentifier($obj->tableName()) :
- $obj->tableName() ;
-
- $dbPrefix = '';
- if (strlen($obj->_database) && in_array($DB->dsn['phptype'],array('mysql','mysqli'))) {
- $dbPrefix = ($quoteIdentifiers
- ? $DB->quoteIdentifier($obj->_database)
- : $obj->_database) . '.';
- }
-
-
- if ($obj->_database == $this->_database) {
- $dbPrefix = '';
- }
-
-
-
-
-
- $objTable = $dbPrefix . $objTable;
-
- $cond = '';
-
-
-
-
- if ( strtolower(get_class($obj)) != 'db_dataobject') {
-
-
-
-
-
- $items = $obj->table();
-
-
-
-
- if (!$items) {
- $this->raiseError(
- "joinAdd: No table definition for {$obj->__table}",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return false;
- }
-
- $ignore_null = !isset($options['disable_null_strings'])
- || !is_string($options['disable_null_strings'])
- || strtolower($options['disable_null_strings']) !== 'full' ;
-
- foreach($items as $k => $v) {
- if (!isset($obj->$k) && $ignore_null) {
- continue;
- }
-
- $kSql = ($quoteIdentifiers ? $DB->quoteIdentifier($k) : $k);
-
- if (DB_DataObject::_is_null($obj,$k)) {
- $obj->whereAdd("{$joinAs}.{$kSql} IS NULL");
- continue;
- }
-
- if ($v & DB_DATAOBJECT_STR) {
- $obj->whereAdd("{$joinAs}.{$kSql} = " . $this->_quote((string) (
- ($v & DB_DATAOBJECT_BOOL) ?
-
-
- (($obj->$k === 'f') ? 0 : (int)(bool) $obj->$k) :
- $obj->$k
- )));
- continue;
- }
- if (is_numeric($obj->$k)) {
- $obj->whereAdd("{$joinAs}.{$kSql} = {$obj->$k}");
- continue;
- }
-
- if (is_object($obj->$k) && is_a($obj->$k,'DB_DataObject_Cast')) {
- $value = $obj->$k->toString($v,$DB);
- if (PEAR::isError($value)) {
- $this->raiseError($value->getMessage() ,DB_DATAOBJECT_ERROR_INVALIDARG);
- return false;
- }
- $obj->whereAdd("{$joinAs}.{$kSql} = $value");
- continue;
- }
-
-
-
- $obj->whereAdd("{$joinAs}.{$kSql} = 0");
- }
- if ($this->_query === false) {
- $this->raiseError(
- "joinAdd can not be run from a object that has had a query run on it,
- clone the object or create a new one and use setFrom()",
- DB_DATAOBJECT_ERROR_INVALIDARGS);
- return false;
- }
- }
-
- if ($obj->_query['condition']) {
- $cond = preg_replace('/^\sWHERE/i','',$obj->_query['condition']);
- if (!$useWhereAsOn) {
- $this->whereAdd($cond);
- }
- }
-
-
-
-
-
- $appendJoin = '';
- if ($obj->_join) {
-
-
-
- if (in_array($DB->dsn["phptype"],array('pgsql'))) {
- $objTable = "($objTable {$obj->_join})";
- } else {
- $appendJoin = $obj->_join;
- }
- }
-
-
-
-
- if ($useWhereAsOn && strlen($cond)) {
- $appendJoin = ' AND ' . $cond . ' ' . $appendJoin;
- }
-
-
-
- $table = $this->tableName();
-
- if ($quoteIdentifiers) {
- $joinAs = $DB->quoteIdentifier($joinAs);
- $table = $DB->quoteIdentifier($table);
- $ofield = (is_array($ofield)) ? array_map(array($DB, 'quoteIdentifier'), $ofield) : $DB->quoteIdentifier($ofield);
- $tfield = (is_array($tfield)) ? array_map(array($DB, 'quoteIdentifier'), $tfield) : $DB->quoteIdentifier($tfield);
- }
-
-
-
- $fullJoinAs = '';
- $addJoinAs = ($quoteIdentifiers ? $DB->quoteIdentifier($obj->tableName()) : $obj->tableName()) != $joinAs;
- if ($addJoinAs) {
-
-
-
- $fullJoinAs = in_array($DB->dsn["phptype"],array('mysql','mysqli','pgsql')) ? "AS {$joinAs}" : $joinAs;
- } else {
-
- $joinAs = $dbPrefix . $joinAs;
- }
-
-
- switch ($joinType) {
- case 'INNER':
- case 'LEFT':
- case 'RIGHT':
-
-
- $jadd = "\n {$joinType} JOIN {$objTable} {$fullJoinAs}";
-
- if (is_array($ofield)) {
- $key_count = count($ofield);
- for($i = 0; $i < $key_count; $i++) {
- if ($i == 0) {
- $jadd .= " ON ({$joinAs}.{$ofield[$i]}={$table}.{$tfield[$i]}) ";
- }
- else {
- $jadd .= " AND {$joinAs}.{$ofield[$i]}={$table}.{$tfield[$i]} ";
- }
- }
- $jadd .= ' ' . $appendJoin . ' ';
- } else {
- $jadd .= " ON ({$joinAs}.{$ofield}={$table}.{$tfield}) {$appendJoin} ";
- }
-
-
- $this->_join .= $jadd;
- break;
-
- case '':
- $this->_join .= "\n , {$objTable} {$fullJoinAs} {$appendJoin}";
- $this->whereAdd("{$joinAs}.{$ofield}={$table}.{$tfield}");
- }
-
-
- return true;
- }
-
- function autoJoin($cfg = array())
- {
-
- $pre_links = $this->links();
- if (!empty($cfg['links'])) {
- $this->links(array_merge( $pre_links , $cfg['links']));
- }
- $map = $this->links( );
-
-
-
- $tabdef = $this->table();
-
-
-
-
- $keys = array_keys($tabdef);
- if (!empty($cfg['exclude'])) {
- $keys = array_intersect($keys, array_diff($keys, $cfg['exclude']));
- }
- if (!empty($cfg['include'])) {
-
- $keys = array_intersect($keys, $cfg['include']);
- }
-
- $selectAs = array();
-
- if (!empty($keys)) {
- $selectAs = array(array( $keys , '%s', false));
- }
-
- $ret = array(
- 'cols' => array(),
- 'join_names' => array(),
- 'count' => false,
- );
-
-
-
- $has_distinct = false;
- if (!empty($cfg['distinct']) && $keys) {
-
-
- $cols = array();
-
-
- foreach($keys as $c) {
-
-
- if ( $cfg['distinct'] == $c) {
- $has_distinct = 'DISTINCT( ' . $this->tableName() .'.'. $c .') as ' . $c;
- $ret['count'] = 'DISTINCT ' . $this->tableName() .'.'. $c .'';
- continue;
- }
-
- $cols = $c;
-
- }
-
-
- $selectAs = empty($cols) ? array() : array(array(array( $cols) , '%s', false)) ;
-
-
-
- }
-
- foreach($keys as $k) {
- $ret['cols'][$k] = $this->tableName(). '.' . $k;
- }
-
-
-
- foreach($map as $ocl=>$info) {
-
- list($tab,$col) = explode(':', $info);
-
- $xx = DB_DataObject::factory($tab);
- if (!is_object($xx) || !is_a($xx, 'DB_DataObject')) {
- continue;
- }
-
-
-
-
-
- $this->joinAdd($xx, 'LEFT', 'join_'.$ocl.'_'. $col, $ocl);
-
- if (!empty($cfg['exclude']) && in_array($ocl, $cfg['exclude'])) {
- continue;
- }
-
- $tabdef = $xx->table();
- $table = $xx->tableName();
-
- $keys = array_keys($tabdef);
-
-
- if (!empty($cfg['exclude'])) {
- $keys = array_intersect($keys, array_diff($keys, $cfg['exclude']));
-
- foreach($keys as $k) {
- if (in_array($ocl.'_'.$k, $cfg['exclude'])) {
- $keys = array_diff($keys, $k);
- }
- }
-
- }
-
- if (!empty($cfg['include'])) {
-
- $nkeys = array();
- foreach($keys as $k) {
- if (in_array( sprintf($ocl.'_%s', $k), $cfg['include'])) {
- $nkeys[] = $k;
- }
- }
- $keys = $nkeys;
- }
-
- if (empty($keys)) {
- continue;
- }
-
- if (!$has_distinct && !empty($cfg['distinct'])) {
- $cols = array();
- foreach($keys as $c) {
- $tn = sprintf($ocl.'_%s', $c);
-
- if ( $tn == $cfg['distinct']) {
-
- $has_distinct = 'DISTINCT( ' . 'join_'.$ocl.'_'.$col.'.'.$c .') as ' . $tn ;
- $ret['count'] = 'DISTINCT join_'.$ocl.'_'.$col.'.'.$c;
-
- continue;
- }
- $cols[] = $c;
-
- }
-
- if (!empty($cols)) {
- $selectAs[] = array($cols, $ocl.'_%s', 'join_'.$ocl.'_'. $col);
- }
-
- } else {
- $selectAs[] = array($keys, $ocl.'_%s', 'join_'.$ocl.'_'. $col);
- }
-
- foreach($keys as $k) {
- $ret['cols'][sprintf('%s_%s', $ocl, $k)] = $tab.'.'.$k;
- $ret['join_names'][sprintf('%s_%s', $ocl, $k)] = sprintf('join_%s_%s.%s',$ocl, $col, $k);
- }
-
- }
-
-
- $this->selectAdd();
-
- if ($has_distinct) {
- $this->selectAdd($has_distinct);
- }
-
- foreach($selectAs as $ar) {
- $this->selectAs($ar[0], $ar[1], $ar[2]);
- }
-
- $this->links( $pre_links );
-
- return $ret;
-
- }
-
-
-
- function sqlValue($value)
- {
- $method = 'sql';
- if (func_num_args() == 2) {
- $method = $value;
- $value = func_get_arg(1);
- }
- require_once 'DB/DataObject/Cast.php';
- return call_user_func(array('DB_DataObject_Cast', $method), $value);
-
- }
-
-
-
- function setFrom($from, $format = '%s', $skipEmpty=false)
- {
- global $_DB_DATAOBJECT;
- $keys = $this->keys();
- $items = $this->table();
-
- if (!$items) {
- $this->raiseError(
- "setFrom:Could not find table definition for {$this->tableName()}",
- DB_DATAOBJECT_ERROR_INVALIDCONFIG);
- return;
- }
- $overload_return = array();
- foreach (array_keys($items) as $k) {
- if (in_array($k,$keys)) {
- continue;
- }
- if (!$k) {
- continue;
- }
-
- $chk = is_object($from) &&
- (version_compare(phpversion(), "5.1.0" , ">=") ?
- property_exists($from, sprintf($format,$k)) :
- array_key_exists( sprintf($format,$k), get_class_vars($from))
- );
-
- if ($chk) {
- $kk = (strtolower($k) == 'from') ? '_from' : $k;
- if (method_exists($this,'set'.$kk)) {
- $ret = $this->{'set'.$kk}($from->{sprintf($format,$k)});
- if (is_string($ret)) {
- $overload_return[$k] = $ret;
- }
- continue;
- }
- $this->$k = $from->{sprintf($format,$k)};
- continue;
- }
-
- if (is_object($from)) {
- continue;
- }
-
- if (empty($from[sprintf($format,$k)]) && $skipEmpty) {
- continue;
- }
-
- if (!isset($from[sprintf($format,$k)]) && !DB_DataObject::_is_null($from, sprintf($format,$k))) {
- continue;
- }
-
- $kk = (strtolower($k) == 'from') ? '_from' : $k;
- if (method_exists($this,'set'. $kk)) {
- $ret = $this->{'set'.$kk}($from[sprintf($format,$k)]);
- if (is_string($ret)) {
- $overload_return[$k] = $ret;
- }
- continue;
- }
- $val = $from[sprintf($format,$k)];
- if (is_a($val, 'DB_DataObject_Cast')) {
- $this->$k = $val;
- continue;
- }
- if (is_object($val) || is_array($val)) {
- continue;
- }
- $ret = $this->fromValue($k,$val);
- if ($ret !== true) {
- $overload_return[$k] = 'Not A Valid Value';
- }
-
- }
- if ($overload_return) {
- return $overload_return;
- }
- return true;
- }
-
- function toArray($format = '%s', $hideEmpty = false)
- {
- global $_DB_DATAOBJECT;
-
-
- $format = $format == '%s' ? false : $format;
-
- $ret = array();
- $rf = ($this->_resultFields !== false) ? $this->_resultFields :
- (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]) ?
- $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid] : false);
-
- $ar = ($rf !== false) ?
- (($hideEmpty === 0) ? $rf : array_merge($rf, $this->table())) :
- $this->table();
- foreach($ar as $k=>$v) {
-
- if (!isset($this->$k)) {
- if (!$hideEmpty) {
- $ret[$format === false ? $k : sprintf($format,$k)] = '';
- }
- continue;
- }
-
- if (method_exists($this,'get'.$k) && !in_array(strtolower($k),array('links','link'))) {
- $ret[$format === false ? $k : sprintf($format,$k)] = $this->{'get'.$k}();
- continue;
- }
-
- $ret[$format === false ? $k : sprintf($format,$k)] = $this->$k;
- }
- if (!$this->_link_loaded) {
- return $ret;
- }
- foreach($this->_link_loaded as $k) {
- $ret[$format === false ? $k : sprintf($format,$k)] = $this->$k->toArray();
-
- }
-
- return $ret;
- }
-
- function validate()
- {
- global $_DB_DATAOBJECT;
- require_once 'Validate.php';
- $table = $this->table();
- $ret = array();
- $seq = $this->sequenceKey();
- $options = $_DB_DATAOBJECT['CONFIG'];
- foreach($table as $key => $val) {
-
-
-
- $method = "Validate" . ucfirst($key);
- if (method_exists($this, $method)) {
- $ret[$key] = $this->$method();
- continue;
- }
-
-
-
- if ($val & DB_DATAOBJECT_NOTNULL && DB_DataObject::_is_null($this, $key)) {
-
- if (($key == $seq[0]) && ($seq[1] == true)) {
- continue;
- }
- $ret[$key] = false;
- continue;
- }
-
-
- if (DB_DataObject::_is_null($this, $key)) {
- if ($val & DB_DATAOBJECT_NOTNULL) {
- $this->debug("'null' field used for '$key', but it is defined as NOT NULL", 'VALIDATION', 4);
- $ret[$key] = false;
- continue;
- }
- continue;
- }
-
-
- if (!isset($this->$key)) {
- continue;
- }
-
-
- if (!is_object($this->$key) && !is_array($this->$key) && !strlen((string) $this->$key)) {
- continue;
- }
-
-
- if (is_object($this->$key) && is_a($this->$key,'DB_DataObject_Cast')) {
- continue;
- }
-
-
-
-
- switch (true) {
-
- case ($val & DB_DATAOBJECT_STR):
- $ret[$key] = Validate::string($this->$key, VALIDATE_PUNCTUATION . VALIDATE_NAME);
- continue;
- case ($val & DB_DATAOBJECT_INT):
- $ret[$key] = Validate::number($this->$key, array('decimal'=>'.'));
- continue;
- }
- }
-
- foreach ($ret as $key => $val) {
- if ($val !== true) {
- return $ret;
- }
- }
- return true;
- }
-
- function getDatabaseConnection()
- {
- global $_DB_DATAOBJECT;
- if (($e = $this->_connect()) !== true) {
- return $e;
- }
- if (!isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $r = false;
- return $r;
- }
- return $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
- }
-
-
-
-
- function getDatabaseResult()
- {
- global $_DB_DATAOBJECT;
- $this->_connect();
- if (!isset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) {
- $r = false;
- return $r;
- }
- return $_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid];
- }
-
-
- function _call($method,$params,&$return) {
-
-
-
- if (strtolower($method) == strtolower(get_class($this))) {
- return true;
- }
- $type = strtolower(substr($method,0,3));
- $class = get_class($this);
- if (($type != 'set') && ($type != 'get')) {
- return false;
- }
-
-
-
-
-
- if (strtolower($method) == 'set_from') {
- $return = $this->toValue('from',isset($params[0]) ? $params[0] : null);
- return true;
- }
-
- $element = substr($method,3);
-
-
-
- $array = array_keys(get_class_vars($class));
-
- if (class_exists('ReflectionClass')) {
- $reflection = new ReflectionClass($class);
- $array = array_keys($reflection->getdefaultProperties());
- }
-
- if (!in_array($element,$array)) {
-
- foreach($array as $k) {
- $case[strtolower($k)] = $k;
- }
- if ((substr(phpversion(),0,1) == 5) && isset($case[strtolower($element)])) {
- trigger_error("PHP5 set/get calls should match the case of the variable",E_USER_WARNING);
- $element = strtolower($element);
- }
-
-
- if (!isset($case[$element])) {
- return false;
- }
-
- $element = $case[$element];
- }
-
-
- if ($type == 'get') {
- $return = $this->toValue($element,isset($params[0]) ? $params[0] : null);
- return true;
- }
-
-
- $return = $this->fromValue($element, $params[0]);
-
- return true;
-
-
- }
-
-
-
-
-
- function fromValue($col,$value)
- {
- global $_DB_DATAOBJECT;
- $options = $_DB_DATAOBJECT['CONFIG'];
- $cols = $this->table();
-
- if (!isset($cols[$col]) || is_a($value, 'DB_DataObject_Cast')) {
- $this->$col = $value;
- return true;
- }
-
- switch (true) {
-
- case ((!($cols[$col] & DB_DATAOBJECT_NOTNULL)) && DB_DataObject::_is_null($value, false)):
- case (is_object($value) && is_a($value,'DB_DataObject_Cast')):
- $this->$col = $value;
- return true;
-
-
- case (($cols[$col] & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($value,false)):
- return false;
-
- case (($cols[$col] & DB_DATAOBJECT_DATE) && ($cols[$col] & DB_DATAOBJECT_TIME)):
-
- if (!$value) {
- $this->$col = '';
- }
-
- if (is_numeric($value)) {
- $this->$col = date('Y-m-d H:i:s', $value);
- return true;
- }
-
-
- $this->$col = (string) $value;
- return true;
-
- case ($cols[$col] & DB_DATAOBJECT_DATE):
-
-
- if (!$value) {
- $this->$col = '';
- return true;
- }
-
- if (is_numeric($value)) {
- $this->$col = date('Y-m-d',$value);
- return true;
- }
-
-
- require_once 'Date.php';
- $x = new Date($value);
- $this->$col = $x->format("%Y-%m-%d");
- return true;
-
- case ($cols[$col] & DB_DATAOBJECT_TIME):
-
- if (!$value) {
- $this->$col = '';
- }
-
- $guess = strtotime($value);
- if ($guess != -1) {
- $this->$col = date('H:i:s', $guess);
- return $return = true;
- }
-
- return false;
-
- case ($cols[$col] & DB_DATAOBJECT_STR):
-
- $this->$col = (string) $value;
- return true;
-
-
- default:
- $this->$col = $value;
- return true;
- }
-
-
-
- }
-
- function toValue($col,$format = null)
- {
- if (is_null($format)) {
- return $this->$col;
- }
- $cols = $this->table();
- switch (true) {
- case (($cols[$col] & DB_DATAOBJECT_DATE) && ($cols[$col] & DB_DATAOBJECT_TIME)):
- if (!$this->$col) {
- return '';
- }
- $guess = strtotime($this->$col);
- if ($guess != -1) {
- return strftime($format, $guess);
- }
-
- return $this->$col;
- case ($cols[$col] & DB_DATAOBJECT_DATE):
- if (!$this->$col) {
- return '';
- }
- $guess = strtotime($this->$col);
- if ($guess != -1) {
- return strftime($format,$guess);
- }
-
- require_once 'Date.php';
- $x = new Date($this->$col);
- return $x->format($format);
-
- case ($cols[$col] & DB_DATAOBJECT_TIME):
- if (!$this->$col) {
- return '';
- }
- $guess = strtotime($this->$col);
- if ($guess > -1) {
- return strftime($format, $guess);
- }
-
- return $this->$col;
-
- case ($cols[$col] & DB_DATAOBJECT_MYSQLTIMESTAMP):
- if (!$this->$col) {
- return '';
- }
- require_once 'Date.php';
-
- $x = new Date($this->$col);
-
- return $x->format($format);
-
-
- case ($cols[$col] & DB_DATAOBJECT_BOOL):
-
- if ($cols[$col] & DB_DATAOBJECT_STR) {
-
- return ($this->$col === 't');
- }
- return (bool) $this->$col;
-
-
- default:
- return sprintf($format,$this->col);
- }
-
- }
-
-
-
-
- function debug($message, $logtype = 0, $level = 1)
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG']['debug']) ||
- (is_numeric($_DB_DATAOBJECT['CONFIG']['debug']) && $_DB_DATAOBJECT['CONFIG']['debug'] < $level)) {
- return;
- }
-
-
- $class = (isset($this) && is_a($this,'DB_DataObject')) ? get_class($this) : 'DB_DataObject';
-
- if (!is_string($message)) {
- $message = print_r($message,true);
- }
- if (!is_numeric( $_DB_DATAOBJECT['CONFIG']['debug']) && is_callable( $_DB_DATAOBJECT['CONFIG']['debug'])) {
- return call_user_func($_DB_DATAOBJECT['CONFIG']['debug'], $class, $message, $logtype, $level);
- }
-
- if (!ini_get('html_errors')) {
- echo "$class : $logtype : $message\n";
- flush();
- return;
- }
- if (!is_string($message)) {
- $message = print_r($message,true);
- }
- $colorize = ($logtype == 'ERROR') ? '<font color="red">' : '<font>';
- echo "<code>{$colorize}<B>$class: $logtype:</B> ". nl2br(htmlspecialchars($message)) . "</font></code><BR>\n";
- }
-
- static function debugLevel($v = null)
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- if ($v !== null) {
- $r = isset($_DB_DATAOBJECT['CONFIG']['debug']) ? $_DB_DATAOBJECT['CONFIG']['debug'] : 0;
- $_DB_DATAOBJECT['CONFIG']['debug'] = $v;
- return $r;
- }
- return isset($_DB_DATAOBJECT['CONFIG']['debug']) ? $_DB_DATAOBJECT['CONFIG']['debug'] : 0;
- }
-
- var $_lastError = false;
-
- function raiseError($message, $type = null, $behaviour = null)
- {
- global $_DB_DATAOBJECT;
-
- if ($behaviour == PEAR_ERROR_DIE && !empty($_DB_DATAOBJECT['CONFIG']['dont_die'])) {
- $behaviour = null;
- }
-
- $error = &PEAR::getStaticProperty('DB_DataObject','lastError');
-
-
-
- DB_DataObject::debug($message,'ERROR',1);
-
-
- if (PEAR::isError($message)) {
- $error = $message;
- } else {
- require_once 'DB/DataObject/Error.php';
- $dor = new PEAR();
- $error = $dor->raiseError($message, $type, $behaviour,
- $opts=null, $userinfo=null, 'DB_DataObject_Error'
- );
- }
-
-
-
- $_DB_DATAOBJECT['LASTERROR'] = $error;
-
- if (isset($this) && is_object($this) && is_subclass_of($this,'db_dataobject')) {
- $this->_lastError = $error;
- }
-
- return $error;
- }
-
- function _loadConfig()
- {
- global $_DB_DATAOBJECT;
- $_DB_DATAOBJECT['CONFIG'] = &PEAR::getStaticProperty('DB_DataObject','options');
- }
-
- function free()
- {
- global $_DB_DATAOBJECT;
-
- if (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) {
- unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]);
- }
- if (isset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) {
- unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]);
- }
-
- $this->_clear_cache();
-
- if (isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
- $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->num_rows = array();
- }
- if (is_array($this->_link_loaded)) {
- foreach ($this->_link_loaded as $do) {
- if (
- !empty($this->{$do}) &&
- is_object($this->{$do}) &&
- method_exists($this->{$do}, 'free')
- ) {
- $this->{$do}->free();
- }
- }
- }
-
- }
-
- function _is_null($obj_or_ar , $prop)
- {
- global $_DB_DATAOBJECT;
-
-
- $isset = $prop === false ? isset($obj_or_ar) :
- (is_array($obj_or_ar) ? isset($obj_or_ar[$prop]) : isset($obj_or_ar->$prop));
-
- $value = $isset ?
- ($prop === false ? $obj_or_ar :
- (is_array($obj_or_ar) ? $obj_or_ar[$prop] : $obj_or_ar->$prop))
- : null;
-
-
-
- $options = $_DB_DATAOBJECT['CONFIG'];
-
- $null_strings = !isset($options['disable_null_strings'])
- || $options['disable_null_strings'] === false;
-
- $crazy_null = isset($options['disable_null_strings'])
- && is_string($options['disable_null_strings'])
- && strtolower($options['disable_null_strings'] === 'full');
-
- if ( $null_strings && $isset && is_string($value) && (strtolower($value) === 'null') ) {
- return true;
- }
-
- if ( $crazy_null && !$isset ) {
- return true;
- }
-
- return false;
-
-
- }
-
-
- static function staticGet($class, $k, $v = null)
- {
- $lclass = strtolower($class);
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
-
- $key = "$k:$v";
- if ($v === null) {
- $key = $k;
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- DB_DataObject::debug("$class $key","STATIC GET - TRY CACHE");
- }
- if (!empty($_DB_DATAOBJECT['CACHE'][$lclass][$key])) {
- return $_DB_DATAOBJECT['CACHE'][$lclass][$key];
- }
- if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
- DB_DataObject::debug("$class $key","STATIC GET - NOT IN CACHE");
- }
- $obj = DB_DataObject::factory(substr($class,strlen($_DB_DATAOBJECT['CONFIG']['class_prefix'])));
- if (PEAR::isError($obj)) {
- $dor = new DB_DataObject();
- $dor->raiseError("could not autoload $class", DB_DATAOBJECT_ERROR_NOCLASS);
- $r = false;
- return $r;
- }
-
- if (!isset($_DB_DATAOBJECT['CACHE'][$lclass])) {
- $_DB_DATAOBJECT['CACHE'][$lclass] = array();
- }
- if (!$obj->get($k,$v)) {
- $dor = new DB_DataObject();
- $dor->raiseError("No Data return from get $k $v", DB_DATAOBJECT_ERROR_NODATA);
-
- $r = false;
- return $r;
- }
- $_DB_DATAOBJECT['CACHE'][$lclass][$key] = $obj;
- return $_DB_DATAOBJECT['CACHE'][$lclass][$key];
- }
-
-
- function staticAutoloadTable($table)
- {
- global $_DB_DATAOBJECT;
- if (empty($_DB_DATAOBJECT['CONFIG'])) {
- DB_DataObject::_loadConfig();
- }
- $p = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ?
- $_DB_DATAOBJECT['CONFIG']['class_prefix'] : '';
- $class = $p . preg_replace('/[^A-Z0-9]/i','_',ucfirst($table));
-
- $ce = substr(phpversion(),0,1) > 4 ? class_exists($class,false) : class_exists($class);
- $class = $ce ? $class : DB_DataObject::_autoloadClass($class);
- return $class;
- }
-
-
-
- function _get_table() { return $this->table(); }
- function _get_keys() { return $this->keys(); }
-
-
-
-
- }
- if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
- if ((phpversion() != '4.3.2-RC1') && (version_compare( phpversion(), "4.3.1") > 0)) {
- if (version_compare( phpversion(), "5") < 0) {
- overload('DB_DataObject');
- }
- $GLOBALS['_DB_DATAOBJECT']['OVERLOADED'] = true;
- }
- }
|