Index: trunk/core/units/general/inp1_parser.php =================================================================== diff -u -N -r8397 -r8436 --- trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 8397) +++ trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 8436) @@ -62,16 +62,14 @@ function InitParser() { - global $objTemplate, $CurrentTheme, $objThemes, $objLanguageCache, $var_list; + global $objTemplate, $CurrentTheme, $objThemes, $var_list; if ($this->InpParsetInited) return true; $theme_id = $this->Application->IsAdmin() ? 1 : $this->Application->GetVar('m_theme'); if ($theme_id) { $CurrentTheme = $objThemes->GetItem($theme_id); $timeout = $CurrentTheme->Get('CacheTimeout'); - $objLanguageCache->LoadTemplateCache($var_list['t'], $timeout, $theme_id); - $objLanguageCache->LoadCachedVars($this->Application->GetVar('m_lang')); $objTemplate = new clsTemplateList(FULL_PATH.THEMES_PATH.'/'); } @@ -83,7 +81,7 @@ { $this->InportalInited = true; /*global $pathtoroot, $FrontEnd, $indexURL, $rootURL, $secureURL, $var_list, $CurrentTheme, - $objThemes, $objConfig, $m_var_list, $timeout, $objLanguages, $objLanguageCache, + $objThemes, $objConfig, $m_var_list, $timeout, $objLanguages, $TemplateRoot, $objTemplate, $html, $objSession, $Errors, $objCatList, $objUsers, $env, $mod_prefix, $ExtraVars, $timestart, $timeend, $timeout, $sqlcount, $totalsql, $template_path, $modules_loaded, $mod_root_cats, $objModules, $objItemTypes;*/ @@ -101,7 +99,7 @@ $template_path, $mod_root_cats, $value, $mod, $ItemTypes, $ParserFiles, $SessionQueryString, $var_list, $objSession, $orderByClause, $TemplateRoot, $ip, $UseSession, $Action, $CookieTest, $sessionId, - $var_list_update, $CurrentTheme, $UserID, $objCurrentUser, $objLanguageCache, + $var_list_update, $CurrentTheme, $UserID, $objCurrentUser, $folder_name, $objLinkList, $tag_override, $timeZones, $siteZone, $serverZone, $lastExpire, $diffZone, $date, $nowDate, $lastExpireDate, $SearchPerformed, $TotalMessagesSent, $ado, $adminDir, $rootURL, $secureURL, $html, $timeout, @@ -149,8 +147,6 @@ } LogEntry("Output Complete\n"); - $objLanguageCache->SaveTemplateCache(); - LogEntry("Templates Cached\n"); $timeend = getmicrotime(); $diff = $timeend - $timestart; Index: trunk/core/kernel/utility/debugger.php =================================================================== diff -u -N -r8413 -r8436 --- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8413) +++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8436) @@ -104,7 +104,7 @@ * * @param string $ip_list semi-column (by default) separated ip address list * @param string $separator ip address separator (default ";") - * + * * @return bool */ function ipMatch($ip_list, $separator = ';') @@ -117,10 +117,10 @@ break; } } - + return $ip_match; } - + /** * Set's default values to constants debugger uses * @@ -265,16 +265,16 @@ { $dump_mode = 'var_dump'; $dumpVars = func_get_args(); - + if ($dumpVars[count($dumpVars) - 1] === 'STRICT') { $dump_mode = 'strict_var_dump'; array_pop($dumpVars); } - + foreach ($dumpVars as $varValue) { $this->Data[] = Array('value' => $varValue, 'debug_type' => $dump_mode); } - + } function prepareHTML($dataIndex) @@ -299,7 +299,7 @@ case 'strict_var_dump': return $this->highlightString( var_export($Data['value'], true) ); break; - + case 'trace': ini_set('memory_limit', '500M'); $trace =& $Data['trace']; @@ -344,19 +344,29 @@ $total = $this->ProfilerTotals[$totals_key]; $div_width = Array(); - $total_width = ($this->getWindowWidth()-10); + $total_width = ($this->getWindowWidth() - 10); $div_width['before'] = round(($total_before / $total) * $total_width); $div_width['current'] = round(($runtime / $total) * $total_width); $div_width['left'] = round((($total - $total_before - $runtime) / $total) * $total_width); $ret = 'Name: '.$Data['description'].'
'; + $additional = isset($Data['additional']) ? $Data['additional'] : Array (); if (isset($Data['file'])) { + array_unshift($additional, Array('name' => 'File', 'value' => $this->getFileLink($Data['file'], $Data['line'], basename($Data['file']).':'.$Data['line']))); + } + array_unshift($additional, Array('name' => 'Runtime', 'value' => $runtime.'s')); + + foreach ($additional as $mixed_param) { + $ret .= '['.$mixed_param['name'].': '.$mixed_param['value'].'] '; + } + + /*if (isset($Data['file'])) { $ret .= '[Runtime: '.$runtime.'s] [File: '.$this->getFileLink($Data['file'], $Data['line'], basename($Data['file']).':'.$Data['line']).']
'; } else { - $ret .= 'Runtime: '.$runtime.'s
'; - } + $ret .= 'Runtime: '.$runtime.'s
'; + }*/ $ret .= '
'; $ret .= '
'; @@ -422,11 +432,11 @@ case 'NULL': return 'NULL'."\n"; break; - + case 'object': return $this->processObject($array, $tab_count); break; - + default: // number or string if (strlen($array) > 200) { @@ -436,9 +446,9 @@ break; } } - + $output = ''; - + $tab_count++; $output .= "Array\n".str_repeat(' ', $tab_count)."(\n"; @@ -484,7 +494,7 @@ } $tab_count--; - $output .= str_repeat(' ', $tab_count).")\n"; + $output .= str_repeat(' ', $tab_count).")\n"; if ($first_line) { $first_line = false; @@ -510,15 +520,15 @@ if ($this->IsBigObject($object)) { return 'SKIPPED (class: '.$object_class.")\n"; } - + $attribute_names = get_class_vars($object_class); if (!$attribute_names) { return "NO_ATTRIBUTES\n"; } else { $output = ''; array_push($this->RecursionStack, $object_class); - + $tabsign = $tab_count ? str_repeat(' ', $tab_count) : ''; foreach ($attribute_names as $attribute_name => $attribute_value) { if (is_object($object->$attribute_name)) { @@ -783,6 +793,19 @@ if (isset($description)) { $this->ProfilerData[$key]['description'] = $description; } + + if (substr($key, 0, 4) == 'sql_') { + $func_arguments = func_get_args(); + $rows_affected = $func_arguments[3]; + + if ($rows_affected > 0) { + $additional = Array ( + Array ('name' => 'Affected Rows', 'value' => $rows_affected), + ); + + $this->ProfilerData[$key]['additional'] =& $additional; + } + } } function profilerAddTotal($total_key, $key = null, $value = null) @@ -843,7 +866,7 @@ if (defined('E_RECOVERABLE_ERROR')) { $error_map['Fatal Error (recoverable)'] = Array(E_RECOVERABLE_ERROR); } - + foreach ($error_map as $error_name => $error_codes) { if (in_array($error_code, $error_codes)) { return $error_name; Index: trunk/kernel/include/globals.php =================================================================== diff -u -N -r8413 -r8436 --- trunk/kernel/include/globals.php (.../globals.php) (revision 8413) +++ trunk/kernel/include/globals.php (.../globals.php) (revision 8436) @@ -867,50 +867,20 @@ } } -function language($phrase,$LangId=0) +function language($phrase, $LangId = 0) { - global $objSession, $objLanguageCache, $objLanguages; - - if ($LangId == 0) { - $LangId = $objSession->Get('Language'); - } - - if ($LangId == 0) { - $LangId = $objLanguages->GetPrimary(); - } - - return $objLanguageCache->GetTranslation($phrase,$LangId); + $application =& kApplication::Instance(); + return $application->Phrase($phrase); } -function admin_language($phrase,$lang=0,$LinkMissing=FALSE) +function admin_language($phrase, $lang = 0, $LinkMissing = false) { - global $objSession, $objLanguageCache, $objLanguages; - - //echo "Language passed: $lang
"; - - if($lang==0) - $lang = $objSession->Get("Language"); - - //echo "Language from session: $lang
"; - - if($lang==0) - $lang = $objLanguages->GetPrimary(); - - //echo "Language after primary: $lang
"; - //echo "Phrase: $phrase
"; - $translation = $objLanguageCache->GetTranslation($phrase,$lang); - if($LinkMissing && substr($translation,0,1)=="!" && substr($translation,-1)=="!") - { - $res = "$translation"; - return $res; - } - else - return $translation; + return language($phrase, $lang); } -function prompt_language($phrase,$lang=0) +function prompt_language($phrase, $lang = 0) { - return admin_language($phrase,$lang,TRUE); + return language($phrase, $lang); } function GetPrimaryTranslation($Phrase) @@ -1626,7 +1596,7 @@ } foreach($main as $vl_key => $vl_value) { - // we need to skip wid here, otherwise empty wid will become 0 and the window name for javascript will be changed (to main_0), + // we need to skip wid here, otherwise empty wid will become 0 and the window name for javascript will be changed (to main_0), // making all links to original (main) window open in new window if ($vl_key == 'wid') continue; if(!$vl_value) $main[$vl_key] = '0'; // unset($main[$vl_key]); Index: trunk/kernel/include/language.php =================================================================== diff -u -N -r8097 -r8436 --- trunk/kernel/include/language.php (.../language.php) (revision 8097) +++ trunk/kernel/include/language.php (.../language.php) (revision 8436) @@ -12,7 +12,7 @@ if($id) $this->LoadFromDatabase($id); } - + function LoadFromDatabase($Id) { global $Errors; @@ -23,11 +23,11 @@ return false; } if($Id) - { + { $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) - { + { $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase"); return false; } @@ -95,7 +95,7 @@ $p = $this->GetItem($id); $p->Set(array("Phrase","LanguageId","Translation","PhraseType", 'Module', 'LastChanged', 'LastChangeIP'), array($Phrase,$LangId,$Translation,$Type, $Module, time(), $_SERVER['REMOTE_ADDR'] )); - $p->Dirty(); + $p->Dirty(); $p->Update(); return $p; } @@ -126,7 +126,7 @@ $sql='INSERT INTO '.GetTablePrefix().'Phrase SELECT Phrase, Translation, PhraseType, 0, LanguageId FROM '.$objSession->GetEditTable('Phrase').' WHERE PhraseId < 0'; $this->adodbConnection->Execute($sql); return; - + //$idlist = array(); $sql = "SELECT * FROM $edit_table"; //echo "performing mass create/update
"; @@ -136,11 +136,11 @@ while($rs && !$rs->EOF) { $data = $rs->fields; - $c = $this->AddItemFromArray($data); - $c->Dirty(); + $c = $this->AddItemFromArray($data); + $c->Dirty(); if($data["PhraseId"]>0) { - $c->Update(); + $c->Update(); } else { @@ -151,17 +151,17 @@ $rs->MoveNext(); } - + // Phrases deleted from temporary table are marked with LanguageId = 0, when saving we need to actually delete them all // The idea was taken from Images edit by Kostja $sql = "DELETE FROM ".$this->SourceTable." WHERE LanguageId = 0"; $this->adodbConnection->Execute($sql); - + if( $GLOBALS['debuglevel'] ) echo $sql."
\n"; $this->adodbConnection->Execute($sql); unset($GLOBALS['_CopyFromEditTable']); } - + function PurgeEditTable() { global $objSession; @@ -172,18 +172,18 @@ function GetPhrase($Phrase,$Lang, $no_db=FALSE) { - $found = FALSE; - + $found = FALSE; + foreach($this->Items as $i) - { + { if($i->Get("Phrase")==$Phrase && $i->Get("LanguageId")==$Lang) { $found = TRUE; break; } } if(!$found && !$no_db) - { + { $sql = "SELECT * FROM ".$this->SourceTable." WHERE Phrase='$Phrase' AND LanguageId='$Lang'"; //echo $sql."
\n"; $rs = $this->adodbConnection->Execute($sql); @@ -219,12 +219,12 @@ function LoadFromDatabase($Id) { global $Errors; - + if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase"); return false; - } + } $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) @@ -238,7 +238,7 @@ $this->SetFromArray($data); $this->Clean(); return true; - } + } function Delete() { @@ -251,14 +251,14 @@ function ParseObject($element) { global $m_var_list,$m_var_list_update, $var_list,$var_list_update, $TemplateRoot; - + //echo "
"; print_r($element); echo "
"; $extra_attribs = ExtraAttributes($element->attributes); if(strtolower($element->name)==$this->TagPrefix) - { - $field = strtolower($element->attributes["_field"]); + { + $field = strtolower($element->attributes["_field"]); switch($field) - { + { case "id": $ret = $this->Get("LanguageId"); break; @@ -271,7 +271,7 @@ case "link": $t = $element->attributes["_template"]; if(strlen($t)) - { + { $var_list_update["t"] = $t; } else @@ -290,7 +290,7 @@ case "icon": $ret = ""; $icon = $this->Get("IconURL"); - + if(strlen($icon)>0) { $file = $TemplateRoot."/".$icon; @@ -342,12 +342,12 @@ } function SetPrimary($lang_id) - { + { $sql = "UPDATE ".$this->SourceTable." SET PrimaryLang=0 "; $this->adodbConnection->Execute($sql); $l = $this->GetItem($lang_id); - $l->Set('PrimaryLang', 1); - $l->Set('Enabled', 1); + $l->Set('PrimaryLang', 1); + $l->Set('Enabled', 1); $l->Update(); $this->m_Primary = $lang_id; } @@ -356,20 +356,20 @@ { static $skip_quering = false; if ($skip_quering) return $this->m_Primary; - + if(!$this->m_Primary) { $sql = 'SELECT '.$Field.' FROM '.$this->SourceTable.' WHERE PrimaryLang = 1'; $this->m_Primary = $this->adodbConnection->GetOne($sql); $skip_quering = true; } - + return $this->m_Primary; } - + function LoadAllLanguages() { - $sql = "SELECT * FROM ".$this->SourceTable; + $sql = "SELECT * FROM ".$this->SourceTable; $this->Query_Item($sql); } @@ -408,7 +408,7 @@ $new_id=$db->GetOne($sql); $db->Execute('UPDATE '.$this->SourceTable.' SET PrimaryLang = 1, Enabled = 1 WHERE LanguageId = '.$new_id); } - $l->Delete(); + $l->Delete(); } function CopyFromEditTable() @@ -424,9 +424,9 @@ while($rs && !$rs->EOF) { $data = $rs->fields; - $c = $this->AddItemFromArray($data); + $c = $this->AddItemFromArray($data); $c->Dirty(); - + if($c->Get('PrimaryLang') == 1) { $c->Set('Enabled',1); @@ -446,18 +446,18 @@ $id = $c->Get("LanguageId"); $phrase_table = $objSession->GetEditTable("Phrase"); $message_table = $objSession->GetEditTable("EmailMessage"); - $sql = "UPDATE $phrase_table SET LanguageId=$id WHERE LanguageId=$oldid"; + $sql = "UPDATE $phrase_table SET LanguageId=$id WHERE LanguageId=$oldid"; $this->adodbConnection->Execute($sql); - $sql = "UPDATE $message_table SET LanguageId=$id WHERE LanguageId=$oldid"; - $this->adodbConnection->Execute($sql); + $sql = "UPDATE $message_table SET LanguageId=$id WHERE LanguageId=$oldid"; + $this->adodbConnection->Execute($sql); } $rs->MoveNext(); } unset($GLOBALS['_CopyFromEditTable']); } function ExportPhrases($file,$LangIds=NULL,$PhraseTypes=null) - { + { $output = array(); $this->Clear(); $where_parts = Array(); @@ -468,41 +468,41 @@ $objXML = new xml_doc(); $RootNode =& $objXML->getTagByID($objXML->createTag("LANGUAGES")); - + $ret = 0; if($this->NumItems()>0) - { + { $phrase_where = isset($PhraseTypes) ? ' AND PhraseType IN ('.$PhraseTypes.')' : ''; $event_where = isset($PhraseTypes) ? ' AND Type+1 IN ('.$PhraseTypes.')' : ''; foreach($this->Items as $l) - { + { $LangRoot =& $objXML->getTagByID($RootNode->addChild($objXML,"LANGUAGE",array("PackName"=>$l->Get("PackName")),"")); $LangRoot->addChild($objXML,"DATEFORMAT",array(),$l->Get("DateFormat")); $LangRoot->addChild($objXML,"TIMEFORMAT",array(),$l->Get("TimeFormat")); $LangRoot->addChild($objXML,"DECIMAL",array(),$l->Get("DecimalPoint")); $LangRoot->addChild($objXML,"THOUSANDS",array(),$l->Get("ThousandSep")); $LangRoot->addChild($objXML,"CHARSET",array(),$l->Get("Charset")); $PhraseRoot =& $objXML->getTagByID($LangRoot->addChild($objXML,"PHRASES")); - + $sql = "SELECT * FROM ".GetTablePrefix()."Phrase WHERE LanguageId=".$l->Get("LanguageId").$phrase_where; $rs=$this->adodbConnection->Execute($sql); while($rs && ! $rs->EOF) { $PhraseRoot->addChild($objXML,"PHRASE",array("Label"=>$rs->fields["Phrase"],"Type"=>$rs->fields["PhraseType"]),base64_encode($rs->fields["Translation"])); $rs->MoveNext(); } - + $EventRoot =& $objXML->getTagByID($LangRoot->addChild($objXML,"EVENTS")); $ev = GetTablePrefix()."Events"; $em = GetTablePrefix()."EmailMessage"; $sql = "SELECT $em.*,$ev.Event,$ev.Type FROM $em INNER JOIN $ev ON ($em.EventId=$ev.EventId) WHERE LanguageId=".$l->Get("LanguageId").$event_where; - $rs = $this->adodbConnection->Execute($sql); + $rs = $this->adodbConnection->Execute($sql); while($rs && !$rs->EOF) - { - $EventRoot->AddChild($objXML,"EVENT",array("MessageType"=>$rs->fields["MessageType"],"Event"=>$rs->fields["Event"],"Type"=>$rs->fields["Type"]),base64_encode($rs->fields["Template"])); + { + $EventRoot->AddChild($objXML,"EVENT",array("MessageType"=>$rs->fields["MessageType"],"Event"=>$rs->fields["Event"],"Type"=>$rs->fields["Type"]),base64_encode($rs->fields["Template"])); $rs->MoveNext(); - } + } } $objXML->generate(); $objXML->xml = str_replace("&","&",$objXML->xml); @@ -514,12 +514,12 @@ } function ReadImportTable($TableName, $SetEnabled=0, $Types="0,1", $OverwitePhrases=FALSE, $MaxInserts=100, $Offset=0) - { + { global $objPhraseList; - + if(!is_object($objPhraseList)) $objPhraseList = new clsPhraseList(); - + $PhraseList = new clsPhraseList(); $TypeArray = explode(",",$Types); $Inserts = 0; @@ -536,7 +536,7 @@ if(is_object($p)) { if($OverwitePhrases) - { + { //$p->debuglevel=1; $p->Set("Translation",$i->Get("Translation")); //echo $i->Get("Translation")."
"; @@ -547,15 +547,15 @@ } else { //$i->debuglevel=1; - $i->Create(); + $i->Create(); } $Inserts++; } } $Offset = $Offset + $Inserts; return $Offset; } - + function PurgeEditTable() { global $objSession; @@ -565,209 +565,4 @@ } } -class clsLanguageCache -{ - var $m_CachedLanguage; - var $FullLoad = FALSE; - var $cache; - var $adodbConnection; - var $TemplateName; - var $TemplateCache; - var $TemplateDate; - var $ThemeId; - - function clsLanguageCache($LangId=NULL) - { - global $objConfig; - - $this->m_CachedLanguage = $LangId; - $this->adodbConnection =&GetADODBConnection(); - $this->Clear(); - } - - function Clear() - { - unset($this->cache); - $this->cache = array(); - $this->TemplateCache = array(); - } - - function LoadLanguage($LangId,$Type) - { - $this->Clear(); - $this->m_CachedLanguage = $LangId; - $this->FullLoad = TRUE; - $sql = "SELECT Phrase,Translation FROM ".GetTablePrefix()."Phrase WHERE LanguageId=$LangId AND PhraseType=$Type"; - $rs = $this->adodbConnection->Execute($sql); - while($rs && !$rs->EOF) - { - $this->cache[$rs->fields["Phrase"]] = $rs->fields["Translation"]; - if(ADODB_EXTENSION>0) - { - adodb_movenext($rs); - } - else - $rs->MoveNext(); - } - - return (count($this->cache)>0); - } - - function GetPhrase($Phrase,$Lang) - { - $t = ""; - $sql = "SELECT PhraseId,Phrase,Translation FROM ".GetTablePrefix()."Phrase WHERE Phrase='$Phrase' AND LanguageId='$Lang'"; - - $rs = $this->adodbConnection->Execute($sql); - if($rs && !$rs->EOF) - { - $t = $rs->fields["Translation"]; - $this->TemplateCache[] = $rs->fields["PhraseId"]; - } - - return $t; - } - - function LoadTemplateCache($t, $timeout, $ThemeId) - { - - $this->TemplateName = $t; - $this->TemplateDate = 0; - $this->ThemeId = $ThemeId; - if($timeout > 0) - { - $sql = "SELECT * FROM ".GetTablePrefix()."PhraseCache WHERE Template='$t' AND ThemeId=$ThemeId"; - $rs = $this->adodbConnection->Execute($sql); - if($rs && !$rs->EOF) - { - $this->TemplateCache = explode(',', $rs->fields['PhraseList']); - $t_length = strlen($rs->fields['PhraseList']) ? 1 : 0; - - $this->TemplateDate = $rs->fields["CacheDate"]; - if(adodb_date("U") < $this->TemplateDate + $timeout || !$t_length) - { - $this->TemplateCache = Array(); - $this->TemplateDate=0; - } - } - else - $this->TemplateDate = -1; - } - else - $this->TemplateDate=-2; - } - - function LoadCachedVars($LangId) - { - if(count($this->TemplateCache)) - { - $values = implode(",",$this->TemplateCache); - $this->FullLoad = FALSE; - $this->m_CachedLanguage = $LangId; - $sql = "SELECT Phrase,Translation FROM ".GetTablePrefix()."Phrase WHERE LanguageId=$LangId AND PhraseId IN ($values)"; - $rs = $this->adodbConnection->Execute($sql); - while($rs && !$rs->EOF) - { - $this->cache[$rs->fields["Phrase"]] = $rs->fields["Translation"]; - if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 ) - adodb_movenext($rs); - else - $rs->MoveNext(); - } - } - } - - function SaveTemplateCache() - { - if($this->TemplateDate==0 || $this->TemplateDate==-1) - { - $value = implode(",",$this->TemplateCache); - if($this->TemplateDate==0) - { - $sql = "UPDATE ".GetTablePrefix()."PhraseCache SET PhraseList='$value',CacheDate=".adodb_date("U"); - $sql .=" WHERE Template='".$this->TemplateName."' AND ThemeId=".$this->ThemeId; - } - else - { - $sql = "REPLACE INTO ".GetTablePrefix()."PhraseCache (Template,PhraseList,CacheDate,ThemeId) VALUES ('"; - $sql .= $this->TemplateName."','$value',".adodb_date("U").",".$this->ThemeId.")"; - } - $this->adodbConnection->Execute($sql); - } - } - - //This function returns a translation for a particular phrase - //if translation is not found then !phrase! is returned. - function GetTranslation($phrase,$language) - { - global $objSession, $LogPhraseLookups,$LangList, $MissingList; - - $missing = FALSE; - if(!$this->FullLoad) - { - $this->RefreshCacheStatus($language); - if(!isset($this->cache[$phrase])) - { - $this->cache[$phrase] = $this->GetPhrase($phrase,$language); - $translation = $this->cache[$phrase]; - //$translation = ""; - } - else - $translation = $this->cache[$phrase]; - } - else - { - $translation = $this->cache[$phrase]; - } - if(!strlen($translation)) - { - $missing = TRUE; - - if($language != 1) - { - $translation=$this->GetTranslation($phrase,1); - } - else - { - $translation = "!".$phrase."!"; - } - } - - if($LogPhraseLookups==TRUE) - { - //if(!is_array($LangList)) - // $LangList = array(); - //$LangList[$phrase] = $LangList; - if($missing) - { - if(!is_array($MissingList)) - { - $MissingList = array(); - } - if(!in_array($phrase,$MissingList)) - $MissingList[] = $phrase; - } - } - - return $translation; - } - - //This function checks if cache is current for current language - //if not clear it out - function RefreshCacheStatus($language) - { - //First remember what language we are caching -// if(!isset($this->m_CachedLanguage)) -// $this->m_CachedLanguage = $language; - - - //If this is the different language, then clear the cache -// if($this->m_CachedLanguage != $language) -// { -// $this->Clear(); -// $this->m_CachedLanguage = $language; -// } - } - -} ?> Index: trunk/kernel/include/itemreview.php =================================================================== diff -u -N -r7635 -r8436 --- trunk/kernel/include/itemreview.php (.../itemreview.php) (revision 7635) +++ trunk/kernel/include/itemreview.php (.../itemreview.php) (revision 8436) @@ -109,6 +109,21 @@ $this->Decrement("Priority"); } + function getMainItem($module_info, $field_name) + { + static $item_data = Array (); + + $resource_id = $this->Get('ItemId'); + if (!isset($item_data[$resource_id])) { + $sql = 'SELECT * + FROM '.TABLE_PREFIX.$module_info['MainTable'].' + WHERE ResourceId = '.$resource_id; + $item_data[$resource_id] = $this->adodbConnection->GetRow($sql); + } + + return $item_data[$resource_id][$field_name]; + } + function ParseObject($element) { global $objConfig, $objCatList, $rootURL, $objUsers, $objModules; @@ -124,16 +139,16 @@ $db=&GetADODBConnection(); $module_info=$objModules->ExecuteFunction('GetModuleInfo','rel_list'); $module_info=$module_info[$this->Get('Module')]; - $ret=$db->GetOne('SELECT '.$module_info['ItemNameField'].' FROM '.GetTablePrefix().$module_info['MainTable'].' WHERE ResourceId='.$this->Get('ItemId')); + $ret = $this->getMainItem($module_info, $module_info['ItemNameField']); break; case 'itemlink': $db=&GetADODBConnection(); $module_info=$objModules->ExecuteFunction('GetModuleInfo','rel_list'); $module_info=$module_info[$this->Get('Module')]; - $prefix=$db->GetOne('SELECT Var FROM '.$objModules->SourceTable.' WHERE Name=\''.$this->Get('Module').'\''); + $prefix = $this->Application->findModule('Name', $this->Get('Module'), 'Var'); - $id=$db->GetOne('SELECT '.$module_info['MainTable'].'Id FROM '.GetTablePrefix().$module_info['MainTable'].' WHERE ResourceId='.$this->Get('ItemId')); + $id = $this->getMainItem($module_info, $module_info['MainTable'].'Id'); $GLOBALS[$prefix.'_var_list_update'][ $module_info['EnvIDField'] ]=$id; /*$env_unparsed=explode(':',$_REQUEST['env']); Index: trunk/kernel/include/adodb/adodb.inc.php =================================================================== diff -u -N -r7867 -r8436 --- trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 7867) +++ trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 8436) @@ -1,10 +1,10 @@ - Manual is at http://php.weblogs.com/adodb_manual - + */ - + if (!function_exists('adodb_safeDefine')) { function adodb_safeDefine($const_name, $value) { @@ -43,62 +43,62 @@ } } } - + if (!defined('_ADODB_LAYER')) { define('_ADODB_LAYER',1); - - //============================================================================================== + + //============================================================================================== // CONSTANT DEFINITIONS - //============================================================================================== + //============================================================================================== adodb_safeDefine('ADODB_BAD_RS','

Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;

'); - + adodb_safeDefine('ADODB_FETCH_DEFAULT',0); adodb_safeDefine('ADODB_FETCH_NUM',1); adodb_safeDefine('ADODB_FETCH_ASSOC',2); adodb_safeDefine('ADODB_FETCH_BOTH',3); - + /* Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. This currently works only with mssql, odbc, oci8po and ibase derived drivers. - + 0 = assoc lowercase field names. $rs->fields['orderid'] 1 = assoc uppercase field names. $rs->fields['ORDERID'] 2 = use native-case field names. $rs->fields['OrderID'] */ if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); - + // allow [ ] @ ` and . in table names adodb_safeDefine('ADODB_TABLE_REGEX','([]0-9a-z_\`\.\@\[-]*)'); - - + + if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); - /** + /** * Set ADODB_DIR to the directory where this file resides... * This constant was formerly called $ADODB_RootPath */ if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__)); - + if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); - - //============================================================================================== + + //============================================================================================== // GLOBAL VARIABLES - //============================================================================================== + //============================================================================================== - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_Database, // last database driver used $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_EXTENSION, // ADODB extension installed $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... - - //============================================================================================== + + //============================================================================================== // GLOBAL SETUP - //============================================================================================== - + //============================================================================================== + if (!defined('ADODB_PHPVER')) { if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { define('ADODB_PHPVER',0x4300); @@ -112,14 +112,14 @@ } $ADODB_EXTENSION = defined('ADODB_EXTENSION'); //if (extension_loaded('dbx')) define('ADODB_DBX',1); - + /** Accepts $src and $dest arrays, replacing string $data */ function ADODB_str_replace($src, $dest, $data) { if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); - + $s = reset($src); $d = reset($dest); while ($s !== false) { @@ -129,109 +129,109 @@ } return $data; } - + function ADODB_Setup() { - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_Database, // last database driver used $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_FETCH_MODE; - + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; - + if (!isset($ADODB_CACHE_DIR)) { $ADODB_CACHE_DIR = '/tmp'; } else { // do not accept url based paths, eg. http:/ or ftp:/ - if (strpos($ADODB_CACHE_DIR,'://') !== false) + if (strpos($ADODB_CACHE_DIR,'://') !== false) die("Illegal path http:// or ftp://"); } - - + + // Initialize random number generator for randomizing cache flushes srand(((double)microtime())*1000000); - + /** * Name of last database driver loaded into memory. Set by ADOLoadCode(). */ $ADODB_Database = ''; - + /** * ADODB version as a string. */ $ADODB_vers = 'V3.60 16 June 2003 (c) 2000-2003 John Lim (jlim@natsoft.com.my). All rights reserved. Released BSD & LGPL.'; - + /** - * Determines whether recordset->RecordCount() is used. + * Determines whether recordset->RecordCount() is used. * Set to false for highest performance -- RecordCount() will always return -1 then * for databases that provide "virtual" recordcounts... */ - $ADODB_COUNTRECS = true; + $ADODB_COUNTRECS = true; } - - - //============================================================================================== + + + //============================================================================================== // CHANGE NOTHING BELOW UNLESS YOU ARE CODING - //============================================================================================== - + //============================================================================================== + ADODB_Setup(); - //============================================================================================== + //============================================================================================== // CLASS ADOFieldObject - //============================================================================================== + //============================================================================================== /** * Helper class for FetchFields -- holds info on a column */ - class ADOFieldObject { + class ADOFieldObject { var $name = ''; var $max_length=0; var $type=""; // additional fields by dannym... (danny_milo@yahoo.com) - var $not_null = false; + var $not_null = false; // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ // so we can as well make not_null standard (leaving it at "false" does not harm anyways) - var $has_default = false; // this one I have done only in mysql and postgres for now ... + var $has_default = false; // this one I have done only in mysql and postgres for now ... // others to come (dannym) var $default_value; // default, if any, and supported. Check has_default first. } - - + + function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { //print "Errorno ($fn errno=$errno m=$errmsg) "; - + $thisConnection->_transOK = false; if ($thisConnection->_oldRaiseFn) { $fn = $thisConnection->_oldRaiseFn; $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); } } - - //============================================================================================== + + //============================================================================================== // CLASS ADOConnection - //============================================================================================== - + //============================================================================================== + /** * Connection object. For connecting to databases, and executing queries. - */ + */ class ADOConnection { // - // PUBLIC VARS + // PUBLIC VARS // var $dataProvider = 'native'; - var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql - var $database = ''; /// Name of database to be used. - var $host = ''; /// The hostname of the database server - var $user = ''; /// The username which is used to connect to the database server. + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $database = ''; /// Name of database to be used. + var $host = ''; /// The hostname of the database server + var $user = ''; /// The username which is used to connect to the database server. var $password = ''; /// Password for the username. For security, we no longer store it. var $debug = false; /// if set to true will output sql statements var $maxblobsize = 256000; /// maximum size of blobs or large text fields -- some databases die otherwise like foxpro - var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase + var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt. var $true = '1'; /// string that represents TRUE for a database @@ -260,9 +260,9 @@ var $sysDate = false; /// name of function that returns the current date var $sysTimeStamp = false; /// name of function that returns the current timestamp var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets - + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' - var $numCacheHits = 0; + var $numCacheHits = 0; var $numCacheMisses = 0; var $pageExecuteCountRows = true; var $uniqueSort = false; /// indicates that all fields in order by must be unique @@ -271,77 +271,77 @@ var $ansiOuter = false; /// whether ansi outer join syntax supported var $autoRollback = false; // autoRollback on PConnect(). var $poorAffectedRows = false; // affectedRows not working or unreliable - + var $fnExecute = false; var $fnCacheExecute = false; var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char var $dbxDriver = false; - + // // PRIVATE VARS // var $_oldRaiseFn = false; var $_transOK = null; - var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. var $_errorMsg = ''; /// A variable which was used to keep the returned last error message. The value will - /// then returned by the errorMsg() function - + /// then returned by the errorMsg() function + var $_queryID = false; /// This variable keeps the last created result link identifier - + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. var $autoCommit = true; /// do not modify this yourself - actually private var $transOff = 0; /// temporarily disable transactions var $transCnt = 0; /// count of nested transactions - + var $fetchMode=false; - + /** * Constructor */ - function ADOConnection() + function ADOConnection() { die('Virtual Class -- cannot instantiate'); } - + /** Get server version info... - - @returns An array with 2 elements: $arr['string'] is the description string, + + @returns An array with 2 elements: $arr['string'] is the description string, and $arr[version] is the version (also a string). */ function ServerInfo() { return array('description' => '', 'version' => ''); } - + function _findvers($str) { if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1]; else return ''; } - + /** * All error messages go through this bottleneck function. * You can define your own handler by defining the function name in ADODB_OUTP. */ function outp($msg,$newline=true) { global $HTTP_SERVER_VARS; - + if (defined('ADODB_OUTP')) { $fn = ADODB_OUTP; $fn($msg,$newline); return; } - + if ($newline) $msg .= "
\n"; - + if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; else echo strip_tags($msg); flush(); } - + /** * Connect to database * @@ -352,15 +352,15 @@ * @param [forceNew] force new connection * * @return true or false - */ - function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) + */ + function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) { if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons - if ($argDatabaseName != "") $this->database = $argDatabaseName; - - $this->_isPersistentConnection = false; + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = false; if ($fn = $this->raiseErrorFn) { if ($forceNew) { if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; @@ -379,14 +379,14 @@ } if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); return false; - } - + } + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); } - - + + /** * Always force a new connection to database - currently only works with oracle * @@ -396,12 +396,12 @@ * @param [argDatabaseName] database * * @return true or false - */ - function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + */ + function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); } - + /** * Establish persistent connect to database * @@ -411,25 +411,25 @@ * @param [argDatabaseName] database * * @return return true or false - */ + */ function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { - if (defined('ADODB_NEVER_PERSIST')) + if (defined('ADODB_NEVER_PERSIST')) return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); - + if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; - if ($argDatabaseName != "") $this->database = $argDatabaseName; - - $this->_isPersistentConnection = true; - + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = true; + if ($fn = $this->raiseErrorFn) { if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; $err = $this->ErrorMsg(); if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); - } else + } else if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); @@ -438,11 +438,11 @@ // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysDate; return $col; // child class implement } - + /** * Should prepare the sql statement and return the stmt resource. * For databases that do not support this, we return the $sql. To ensure @@ -457,7 +457,7 @@ * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * - */ + */ function Prepare($sql) { return $sql; @@ -476,12 +476,12 @@ * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * - */ + */ function PrepareSP($sql) { return $this->Prepare($sql); } - + /** * PEAR DB Compat */ @@ -494,18 +494,18 @@ { $s = $this->qstr($s,false); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function ErrorNative() { return $this->ErrorNo(); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function nextId($seq_name) { @@ -523,19 +523,19 @@ { return false; } - + function CommitLock($table) { return $this->CommitTrans(); } - + function RollbackLock($table) { return $this->RollbackTrans(); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. * * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical * for easy porting :-) @@ -544,20 +544,20 @@ * @returns The previous fetch mode */ function SetFetchMode($mode) - { + { $old = $this->fetchMode; $this->fetchMode = $mode; - + if ($old === false) { global $ADODB_FETCH_MODE; return $ADODB_FETCH_MODE; } return $old; } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function &Query($sql, $inputarr=false) { @@ -566,18 +566,18 @@ return $rs; } - + /** * PEAR DB Compat - do not use internally */ function &LimitQuery($sql, $offset, $count) { - $rs = &$this->SelectLimit($sql, $count, $offset); // swap + $rs = &$this->SelectLimit($sql, $count, $offset); // swap if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); return $rs; } - + /** * PEAR DB Compat - do not use internally */ @@ -586,13 +586,13 @@ return $this->Close(); } - /* + /* Usage in oracle $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',64); $db->Execute(); - + @param $stmt Statement returned by Prepare() or PrepareSP(). @param $var PHP variable to bind to @param $name Name of stored procedure variable name to bind to. @@ -605,11 +605,11 @@ { return false; } - + /** Improved method of initiating a transaction. Used together with CompleteTrans(). Advantages include: - + a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. Only the outermost block is treated as a transaction.
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
@@ -618,26 +618,26 @@ */ function StartTrans($errfn = 'ADODB_TransMonitor') { - + if ($this->transOff > 0) { $this->transOff += 1; return; } - + $this->_oldRaiseFn = $this->raiseErrorFn; $this->raiseErrorFn = $errfn; $this->_transOK = true; - + if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); $this->BeginTrans(); $this->transOff = 1; } - + /** Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. - - @autoComplete if true, monitor sql errors and commit and rollback as appropriate, + + @autoComplete if true, monitor sql errors and commit and rollback as appropriate, and if set to false force rollback even if no SQL error detected. @returns true on commit, false on rollback. */ @@ -648,14 +648,14 @@ return true; } $this->raiseErrorFn = $this->_oldRaiseFn; - + $this->transOff = 0; if ($this->_transOK && $autoComplete) $this->CommitTrans(); else $this->RollbackTrans(); - + return $this->_transOK; } - + /* At the end of a StartTrans/CompleteTrans block, perform a rollback. */ @@ -668,20 +668,20 @@ } function getmicrotime() - { - list($usec, $sec) = explode(" ",microtime()); - return ((float)$usec + (float)$sec); - } + { + list($usec, $sec) = explode(" ",microtime()); + return ((float)$usec + (float)$sec); + } /** - * Execute SQL + * Execute SQL * * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) * @param [inputarr] holds the input data to bind to. Null elements will be set to null. * @param [arg3] reserved for john lim for future use * @return RecordSet or false */ - function &Execute($sql,$inputarr=false,$arg3=false) + function &Execute($sql,$inputarr=false,$arg3=false) { global $pathtoroot, $totalsql, $sqlcount; if ($this->fnExecute) { @@ -696,26 +696,26 @@ $sql .= $sqlarr[$i]; // from Ron Baldwin - // Only quote string types + // Only quote string types if (gettype($v) == 'string') $sql .= $this->qstr($v); else if ($v === null) $sql .= 'NULL'; else $sql .= $v; $i += 1; - + } $sql .= $sqlarr[$i]; - if ($i+1 != sizeof($sqlarr)) + if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); $inputarr = false; } // debug version of query if ($this->debug && isset($GLOBALS['debugger']) ) { global $HTTP_SERVER_VARS, $debugger; - + $ss = ''; if ($inputarr) { foreach ($inputarr as $kk => $vv) { @@ -725,16 +725,16 @@ $ss = "[ $ss ]"; } $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql); - + // check if running from browser or command-line $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); - + if ($inBrowser) ADOConnection::outp( "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); else ADOConnection::outp( "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false); flush(); - + $profileSQLs = constOn('DBG_SQL_PROFILE'); if ($profileSQLs) { $isSkipTable = isSkipTable($sql); @@ -744,14 +744,14 @@ } $this->_queryID = $this->_query($sql,$inputarr,$arg3); if ($profileSQLs && !$isSkipTable) { - $debugger->profileFinish('sql_'.$queryID); + $debugger->profileFinish('sql_'.$queryID, null, null, $this->Affected_Rows()); $debugger->profilerAddTotal('sql', 'sql_'.$queryID); } - /* + /* Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql because ErrorNo() calls Execute('SELECT @ERROR'), causing recure */ - if ($this->databaseType == 'mssql') { + if ($this->databaseType == 'mssql') { // ErrorNo is a slow function call in mssql, and not reliable // in PHP 4.0.6 if($emsg = $this->ErrorMsg()) { @@ -761,33 +761,33 @@ flush(); } } - } else + } else if (!$this->_queryID) { $e = $this->ErrorNo(); $m = $this->ErrorMsg(); $errorLevel = constOn('DBG_SQL_FAILURE') && !constOn('IS_INSTALL') ? E_USER_ERROR : E_USER_WARNING; $debugger->appendTrace(); - + $error_msg = ''.$m.' ('.$e.')
SQL: '.$debugger->formatSQL($sql); $long_id = $debugger->mapLongError($error_msg); trigger_error( substr($m.' ('.$e.') ['.$sql.']',0,1000).' #'.$long_id, $errorLevel); - + ADOConnection::outp($e .': '. $m ); flush(); } } else { // non-debug version of query - - + + $sqlcount++; $sql_start = $this->getmicrotime(); $this->_queryID =@$this->_query($sql,$inputarr,$arg3); $sql_end = $this->getmicrotime(); $elapsed = $sql_end - $sql_start; - $totalsql += $elapsed; + $totalsql += $elapsed; //$fp = @fopen ($pathtoroot."log.sql", "aw"); - $starttime = 0; // by Alex (variable was not defined) + $starttime = 0; // by Alex (variable was not defined) $d=time()-$starttime; $t=date("Y-m-d\tH:i:s",$starttime); $e = round($elapsed,5); @@ -807,20 +807,20 @@ $rs = new ADORecordSet_empty(); return $rs; } - + // return real recordset from select statement $rsclass = "ADORecordSet_".$this->databaseType; $rs = new $rsclass($this->_queryID,$this->fetchMode); // &new not supported by older PHP versions $rs->connection = &$this; // Pablo suggestion $rs->Init(); if (is_array($sql)) $rs->sql = $sql[0]; else $rs->sql = $sql; - + if ($rs->_numOfRows <= 0) { global $ADODB_COUNTRECS; - + if ($ADODB_COUNTRECS) { - if (!$rs->EOF){ + if (!$rs->EOF){ $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql)); $rs->_queryID = $this->_queryID; } else @@ -835,7 +835,7 @@ if (empty($this->_genSeqSQL)) return false; return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); } - + function DropSequence($seqname) { if (empty($this->_dropSeqSQL)) return false; @@ -856,7 +856,7 @@ if (!$this->hasGenID) { return 0; // formerly returns false pre 1.60 } - + $getnext = sprintf($this->_genIDSQL,$seqname); $rs = @$this->Execute($getnext); if (!$rs) { @@ -865,84 +865,84 @@ } if ($rs && !$rs->EOF) $this->genID = reset($rs->fields); else $this->genID = 0; // false - + if ($rs) $rs->Close(); return $this->genID; - } + } /** * @return the last inserted ID. Not all databases support this. - */ + */ function Insert_ID() { if ($this->hasInsertID) return $this->_insertid(); if ($this->debug) ADOConnection::outp( '

Insert_ID error

'); return false; } - - + + /** * Portable Insert ID. Pablo Roca * * @return the last inserted ID. All databases support this. But aware possible * problems in multiuser environments. Heavy test this before deploying. - */ - function PO_Insert_ID($table="", $id="") + */ + function PO_Insert_ID($table="", $id="") { if ($this->hasInsertID){ return $this->Insert_ID(); } else { return $this->GetOne("SELECT MAX($id) FROM $table"); } - } - - + } + + /** * @return # rows affected by UPDATE/DELETE - */ + */ function Affected_Rows() { if ($this->hasAffectedRows) { $val = $this->_affectedrows(); return ($val < 0) ? false : $val; } - + if ($this->debug) ADOConnection::outp( '

Affected_Rows error

',false); return false; } - - + + /** * @return the last error message */ function ErrorMsg() { return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; } - - + + /** * @return the last error number. Normally 0 means no error. */ - function ErrorNo() + function ErrorNo() { return ($this->_errorMsg) ? -1 : 0; } - + function MetaError($err=false) { include_once(ADODB_DIR."/adodb-error.inc.php"); if ($err === false) $err = $this->ErrorNo(); return adodb_error($this->dataProvider,$this->databaseType,$err); } - + function MetaErrorMsg($errno) { include_once(ADODB_DIR."/adodb-error.inc.php"); return adodb_errormsg($errno); } - + /** * @returns an array with the primary key columns in it. */ @@ -960,24 +960,24 @@ if (sizeof($p)) return $p; return false; } - - + + /** * Choose a database to connect to. Many databases do not support this. * * @param dbName is the name of the database to select * @return true or false */ - function SelectDB($dbName) + function SelectDB($dbName) {return false;} - - + + /** - * Will select, getting rows from $offset (1-based), for $nrows. + * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. - * eg. + * eg. * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) * @@ -995,14 +995,14 @@ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) { if ($this->hasTop && $nrows > 0) { - // suggested by Reinhard Balling. Access requires top after distinct + // suggested by Reinhard Balling. Access requires top after distinct // Informix requires first before distinct - F Riosa $ismssql = (strpos($this->databaseType,'mssql') !== false); if ($ismssql) $isaccess = false; else $isaccess = (strpos($this->databaseType,'access') !== false); - + if ($offset <= 0) { - + // access includes ties in result if ($isaccess) { $sql = preg_replace( @@ -1028,14 +1028,14 @@ } } } - + // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + if ($offset>0){ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr,$arg3); else $rs = &$this->Execute($sql,$inputarr,$arg3); @@ -1050,8 +1050,8 @@ //print_r($rs); return $rs; } - - + + /** * Convert database recordset to an array recordset * input recordset's cursor should be at beginning, and @@ -1065,7 +1065,7 @@ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) { if (! $rs) return false; - + $dbtype = $rs->databaseType; if (!$dbtype) { $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? @@ -1083,23 +1083,23 @@ $arr =& $rs->GetArrayLimit($nrows,$offset); //print_r($arr); if ($close) $rs->Close(); - + $arrayClass = $this->arrayClass; - + $rs2 = new $arrayClass(); $rs2->connection = &$this; $rs2->sql = $rs->sql; $rs2->dataProvider = $this->dataProvider; $rs2->InitArrayFields($arr,$flds); return $rs2; } - - + + function &GetArray($sql, $inputarr=false) { return $this->GetAll($sql,$inputarr); } - + /** * Return first element of first row of sql statement. Recordset is disposed * for you. @@ -1112,31 +1112,31 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $ret = false; $rs = &$this->Execute($sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } + } $ADODB_COUNTRECS = $crecs; return $ret; } - + function CacheGetOne($secs2cache,$sql=false,$inputarr=false) { $ret = false; $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } - + } + return $ret; } - + function GetCol($sql, $inputarr = false, $trim = false) - { + { $rv = false; $rs = &$this->Execute($sql, $inputarr); @@ -1154,10 +1154,10 @@ } $rs->Close(); } - + return $rv; } - + function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) { $rv = false; @@ -1178,21 +1178,21 @@ } return $rv; } - + /* Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database. - + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. */ function OffsetDate($dayFraction,$date=false) - { + { if (!$date) $date = $this->sysDate; return '('.$date.'+'.$dayFraction.')'; } - - + + /** * Return all rows. Compat with PEAR DB * @@ -1202,40 +1202,40 @@ function &GetAll($sql,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs = $this->Execute($sql,$inputarr); $ADODB_COUNTRECS = $savec; - - if (!$rs) + + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - + function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); $ADODB_COUNTRECS = $savec; - - if (!$rs) + + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; - + $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - - - + + + /** * Return one row of sql statement. Recordset is disposed for you. * @@ -1247,20 +1247,20 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $rs = $this->Execute($sql,$inputarr); - + $ADODB_COUNTRECS = $crecs; if ($rs) { $arr = array(); if (!$rs->EOF) $arr = $rs->fields; $rs->Close(); return $arr; } - + return false; } - + function &CacheGetRow($secs2cache,$sql=false,$inputarr=false) { $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); @@ -1272,9 +1272,9 @@ } return false; } - + /** - * Insert or replace a single record. Note: this is not the same as MySQL's replace. + * Insert or replace a single record. Note: this is not the same as MySQL's replace. * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... @@ -1290,15 +1290,15 @@ * * Currently blob replace not supported * - * returns 0 = fail, 1 = update, 2 = insert + * returns 0 = fail, 1 = update, 2 = insert */ - + function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) { if (count($fieldArray) == 0) return 0; $first = true; $uSet = ''; - + if (!is_array($keyCol)) { $keyCol = array($keyCol); } @@ -1308,14 +1308,14 @@ $fieldArray[$k] = $v; } if (in_array($k,$keyCol)) continue; // skip UPDATE if is key - + if ($first) { - $first = false; + $first = false; $uSet = "$k=$v"; } else $uSet .= ",$k=$v"; } - + $first = true; foreach ($keyCol as $v) { if ($first) { @@ -1325,55 +1325,55 @@ $where .= " and $v=$fieldArray[$v]"; } } - + if ($uSet) { $update = "UPDATE $table SET $uSet WHERE $where"; - + $rs = $this->Execute($update); if ($rs) { if ($this->poorAffectedRows) { /* - The Select count(*) wipes out any errors that the update would have returned. + The Select count(*) wipes out any errors that the update would have returned. http://phplens.com/lens/lensforum/msgs.php?id=5696 */ if ($this->ErrorNo()<>0) return 0; - + # affected_rows == 0 if update field values identical to old values - # for mysql - which is silly. - + # for mysql - which is silly. + $cnt = $this->GetOne("select count(*) from $table where $where"); if ($cnt > 0) return 1; // record already exists } else if (($this->Affected_Rows()>0)) return 1; } - + } // print "

Error=".$this->ErrorNo().'

'; $first = true; foreach($fieldArray as $k => $v) { if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col - + if ($first) { - $first = false; + $first = false; $iCols = "$k"; $iVals = "$v"; } else { $iCols .= ",$k"; $iVals .= ",$v"; - } + } } - $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; + $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; $rs = $this->Execute($insert); return ($rs) ? 2 : 0; } - - + + /** - * Will select, getting rows from $offset (1-based), for $nrows. + * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. - * eg. + * eg. * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based) * @@ -1388,7 +1388,7 @@ * @return the recordset ($rs->databaseType == 'array') */ function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false) - { + { if (!is_numeric($secs2cache)) { if ($sql === false) $sql = -1; if ($offset == -1) $offset = false; @@ -1399,20 +1399,20 @@ return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); } } - + /** - * Flush cached recordsets that match a particular $sql statement. + * Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache. */ function CacheFlush($sql=false,$inputarr=false) { global $ADODB_CACHE_DIR; - + if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { if (strpos(strtoupper(PHP_OS),'WIN') !== false) { $cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache'; } else { - $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache'; + $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache'; // old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`'; } if ($this->debug) { @@ -1421,12 +1421,12 @@ exec($cmd); } return; - } + } $f = $this->_gencachename($sql.serialize($inputarr),false); adodb_write_file($f,''); // is adodb_write_file needed? @unlink($f); } - + /** * Private function to generate filename for caching. * Filename is generated based on: @@ -1436,30 +1436,30 @@ * - database name * - userid * - * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). - * Assuming that we can have 50,000 files per directory with good performance, + * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). + * Assuming that we can have 50,000 files per directory with good performance, * then we can scale to 12.8 million unique cached recordsets. Wow! */ function _gencachename($sql,$createdir) { global $ADODB_CACHE_DIR; - + $m = md5($sql.$this->databaseType.$this->database.$this->user); $dir = $ADODB_CACHE_DIR.'/'.substr($m,0,2); if ($createdir && !file_exists($dir)) { $oldu = umask(0); - if (!mkdir($dir,0771)) + if (!mkdir($dir,0771)) if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); umask($oldu); } return $dir.'/adodb_'.$m.'.cache'; } - - + + /** * Execute SQL, caching recordsets. * - * @param [secs2cache] seconds to cache data, set to 0 to force query. + * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to @@ -1475,10 +1475,10 @@ $secs2cache = $this->cacheSecs; } include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); - + $md5file = $this->_gencachename($sql.serialize($inputarr),true); $err = ''; - + if ($secs2cache > 0){ $rs = &csv2rs($md5file,$err,$secs2cache); $this->numCacheHits += 1; @@ -1500,7 +1500,7 @@ $eof = $rs->EOF; $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately $txt = _rs2serialize($rs,false,$sql); // serialize - + if (!adodb_write_file($md5file,$txt,$this->debug)) { if ($fn = $this->raiseErrorFn) { $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this); @@ -1509,10 +1509,10 @@ } if ($rs->EOF && !$eof) { $rs->MoveFirst(); - //$rs = &csv2rs($md5file,$err); + //$rs = &csv2rs($md5file,$err); $rs->connection = &$this; // Pablo suggestion - } - + } + } else @unlink($md5file); } else { @@ -1522,28 +1522,28 @@ } // ok, set cached object found $rs->connection = &$this; // Pablo suggestion - if ($this->debug){ + if ($this->debug){ global $HTTP_SERVER_VARS; - + $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); $ttl = $rs->timeCreated + $secs2cache - time(); $s = is_array($sql) ? $sql[0] : $sql; if ($inBrowser) $s = ''.htmlspecialchars($s).''; - + ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); } } return $rs; } - - + + /** * Generates an Update Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset - * that is run against a single table and sql should only + * that is run against a single table and sql should only * be a simple select stmt with no groupby/orderby/limit * * "Jonathan Younger" @@ -1564,21 +1564,21 @@ * that is run against a single table. */ function GetInsertSQL(&$rs, $arrFields,$magicq=false) - { + { include_once(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getinsertsql($this,$rs,$arrFields,$magicq); } - + /** * Update a blob column, given a where clause. There are more sophisticated * blob handling functions that we could have implemented, but all require * a very complex API. Instead we have chosen something that is extremely - * simple to understand and use. + * simple to understand and use. * * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. * - * Usage to update a $blobvalue which has a primary key blob_id=1 into a + * Usage to update a $blobvalue which has a primary key blob_id=1 into a * field blobtable.blobcolumn: * * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); @@ -1588,7 +1588,7 @@ * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); */ - + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; @@ -1597,7 +1597,7 @@ /** * Usage: * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); - * + * * $blobtype supports 'BLOB' and 'CLOB' * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); @@ -1611,17 +1611,17 @@ fclose($fd); return $this->UpdateBlob($table,$column,$val,$where,$blobtype); } - + function BlobDecode($blob) { return $blob; } - + function BlobEncode($blob) { return $blob; } - + /** * Usage: * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB'); @@ -1633,8 +1633,8 @@ { return $this->UpdateBlob($table,$column,$val,$where,'CLOB'); } - - + + /** * $meta contains the desired type, which could be... * C for character. You will have to define the precision yourself. @@ -1648,8 +1648,8 @@ * I for integer * R for autoincrement counter/integer * and if you want to use double-byte, add a 2 to the end, like C2 or X2. - * * + * * @return the actual type of the data or false if no such type available */ function ActualType($meta) @@ -1659,13 +1659,13 @@ case 'X': return 'VARCHAR'; case 'B': - + case 'D': case 'T': case 'L': - + case 'R': - + case 'I': case 'N': return false; @@ -1679,101 +1679,101 @@ { return 255; // make it conservative if not defined } - - + + /* * Maximum size of X field */ function TextMax() { return 4000; // make it conservative if not defined } - + /** * Close Connection */ - function Close() + function Close() { return $this->_close(); - - // "Simon Lee" reports that persistent connections need + + // "Simon Lee" reports that persistent connections need // to be closed too! //if ($this->_isPersistentConnection != true) return $this->_close(); - //else return true; + //else return true; } - + /** * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). * * @return true if succeeded or false if database does not support transactions */ function BeginTrans() {return false;} - - + + /** * If database does not support transactions, always return true as data always commited * * @param $ok set to false to rollback transaction, true to commit * * @return true/false. */ - function CommitTrans($ok=true) + function CommitTrans($ok=true) { return true;} - - + + /** * If database does not support transactions, rollbacks always fail, so return false * * @return true/false. */ - function RollbackTrans() + function RollbackTrans() { return false;} /** - * return the databases that the driver can connect to. + * return the databases that the driver can connect to. * Some databases will return an empty array. * * @return an array of database names. */ - function MetaDatabases() + function MetaDatabases() { global $ADODB_FETCH_MODE; - + if ($this->metaDatabasesSQL) { - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $arr = $this->GetCol($this->metaDatabasesSQL); if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - + $ADODB_FETCH_MODE = $save; + return $arr; } - + return false; } - + /** * @return array of tables for current database. - */ - function &MetaTables() + */ + function &MetaTables() { global $ADODB_FETCH_MODE; - + if ($this->metaTablesSQL) { // complicated state saving by the need for backward compat - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $rs = $this->Execute($this->metaTablesSQL); if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - + $ADODB_FETCH_MODE = $save; + if ($rs === false) return false; $arr =& $rs->GetArray(); $arr2 = array(); @@ -1785,18 +1785,18 @@ } return false; } - - + + /** - * List columns in a database as an array of ADOFieldObjects. + * List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * * @param table table name to query * @param upper uppercase table name (required by some databases) * * @return array of ADOFieldObjects for current table. - */ - function &MetaColumns($table,$upper=true) + */ + function &MetaColumns($table,$upper=true) { global $ADODB_FETCH_MODE; @@ -1820,53 +1820,53 @@ if ($fld->scale>0) $fld->max_length += 1; } else $fld->max_length = $rs->fields[2]; - - $retarr[strtoupper($fld->name)] = $fld; + $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - + /** - * List columns names in a table as an array. + * List columns names in a table as an array. * @param table table name to query * * @return array of column names for current table. - */ - function &MetaColumnNames($table) + */ + function &MetaColumnNames($table) { $objarr =& $this->MetaColumns($table); if (!is_array($objarr)) return false; - + $arr = array(); foreach($objarr as $v) { $arr[] = $v->name; } return $arr; } - + /** * Different SQL databases used different methods to combine strings together. - * This function provides a wrapper. - * + * This function provides a wrapper. + * * param s variable number of string parameters * * Usage: $db->Concat($str1,$str2); - * + * * @return concatenated string - */ + */ function Concat() - { + { $arr = func_get_args(); return implode($this->concat_operator, $arr); } - - + + /** * Converts a date "d" to a string that the database can understand. * @@ -1876,19 +1876,19 @@ */ function DBDate($d) { - + if (empty($d) && $d !== 0) return 'null'; if (is_string($d) && !is_numeric($d)) { if ($d === 'null') return $d; if ($this->isoDates) return "'$d'"; $d = ADOConnection::UnixDate($d); } - + return adodb_date($this->fmtDate,$d); } - - + + /** * Converts a timestamp "ts" to a string that the database can understand. * @@ -1905,10 +1905,10 @@ if ($this->isoDates) return "'$ts'"; else $ts = ADOConnection::UnixTimeStamp($ts); } - + return adodb_date($this->fmtTimeStamp,$ts); } - + /** * Also in ADORecordSet. * @param $v is a date string in YYYY-MM-DD format @@ -1917,15 +1917,15 @@ */ function UnixDate($v) { - if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } - + /** * Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format @@ -1934,16 +1934,16 @@ */ function UnixTimeStamp($v) { - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; - + // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } - + /** * Also in ADORecordSet. * @@ -1954,7 +1954,7 @@ * * @return a date formated as user desires */ - + function UserDate($v,$fmt='Y-m-d') { $tt = $this->UnixDate($v); @@ -1963,50 +1963,50 @@ else if ($tt == 0) return $this->emptyDate; else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } - + return adodb_date($fmt,$tt); - + } - - + + /** * Correctly quotes a string so that all strings are escaped. We prefix and append * to the string single-quotes. * An example is $db->qstr("Don't bother",magic_quotes_runtime()); - * + * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. * * @return quoted string to be sent back to database */ function qstr($s,$magic_quotes=false) - { + { if (!$magic_quotes) { - + if ($this->replaceQuote[0] == '\\'){ // only since php 4.0.5 $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s)); } return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); - + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything return "'$s'"; else {// change \' to '' for sybase/mssql $s = str_replace('\\\\','\\',$s); return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; } } - - + + /** - * Will select the supplied $page number from a recordset, given that it is paginated in pages of - * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. @@ -2022,18 +2022,18 @@ * NOTE: phpLens uses a different algorithm and does not use PageExecute(). * */ - function &PageExecute($sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0) + function &PageExecute($sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0) { include_once(ADODB_DIR.'/adodb-lib.inc.php'); if ($this->pageExecuteCountRows) return _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $arg3, $secs2cache); return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $arg3, $secs2cache); } - - + + /** - * Will select the supplied $page number from a recordset, given that it is paginated in pages of - * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination. * * @param secs2cache seconds to cache data, set to 0 to force query @@ -2044,35 +2044,35 @@ * @param [arg3] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == 'array') */ - function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false, $arg3=false) + function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false, $arg3=false) { /*switch($this->dataProvider) { case 'postgres': - case 'mysql': + case 'mysql': break; default: $secs2cache = 0; break; }*/ return $this->PageExecute($sql,$nrows,$page,$inputarr,$arg3,$secs2cache); } } // end class ADOConnection - - - - //============================================================================================== + + + + //============================================================================================== // CLASS ADOFetchObj - //============================================================================================== - + //============================================================================================== + /** * Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). */ class ADOFetchObj { }; - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet_empty - //============================================================================================== - + //============================================================================================== + /** * Lightweight recordset when there are no records to be returned */ @@ -2091,17 +2091,17 @@ function FetchRow() {return false;} function FieldCount(){ return 0;} } - - //============================================================================================== + + //============================================================================================== // DATE AND TIME FUNCTIONS - //============================================================================================== + //============================================================================================== if( !function_exists('adodb_mktime') ) include_once(ADODB_DIR.'/adodb-time.inc.php'); - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet - //============================================================================================== - - + //============================================================================================== + + /** * RecordSet class that represents the dataset returned by the database. * To keep memory overhead low, this class holds only the current row in memory. @@ -2110,16 +2110,16 @@ */ class ADORecordSet { /* - * public variables + * public variables */ var $dataProvider = "native"; var $fields = false; /// holds the current row data var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob /// in other words, we use a text area for editting. var $canSeek = false; /// indicates that seek is supported var $sql; /// sql text - var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. - + var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. + var $emptyTimeStamp = ' '; /// what to display when $time==0 var $emptyDate = ' '; /// what to display when $time==0 var $debug = false; @@ -2129,7 +2129,7 @@ var $fetchMode; /// default fetch mode var $connection = false; /// the parent connection /* - * private variables + * private variables */ var $_numOfRows = -1; /** number of rows, or -1 */ var $_numOfFields = -1; /** number of fields in recordset */ @@ -2139,27 +2139,27 @@ var $_inited = false; /** Init() should only be called once */ var $_obj; /** Used by FetchObj */ var $_names; /** Used by FetchObj */ - + var $_currentPage = -1; /** Added by Iv�n Oliva to implement recordset pagination */ var $_atFirstPage = false; /** Added by Iv�n Oliva to implement recordset pagination */ var $_atLastPage = false; /** Added by Iv�n Oliva to implement recordset pagination */ - var $_lastPageNo = -1; + var $_lastPageNo = -1; var $_maxRecordCount = 0; var $dateHasTime = false; - + /** * Constructor * * @param queryID this is the queryID returned by ADOConnection->_query() * */ - function ADORecordSet($queryID) + function ADORecordSet($queryID) { $this->_queryID = $queryID; } - - - + + + function Init() { if ($this->_inited) return; @@ -2169,9 +2169,9 @@ $this->_numOfRows = 0; $this->_numOfFields = 0; } - + if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { - + $this->_currentRow = 0; if ($this->EOF = ($this->_fetch() === false)) { $this->_numOfRows = 0; // _numOfRows could be -1 @@ -2180,11 +2180,11 @@ $this->EOF = true; } } - - + + /** * Generate a SELECT tag string from a recordset, and return the string. - * If the recordset has 2 cols, we treat the 1st col as the containing + * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the FIRST column. * @@ -2195,7 +2195,7 @@ * @param [size] #rows to show for listbox. not used by popup * @param [selectAttr] additional attributes to defined for SELECT tag. * useful for holding javascript onChange='...' handlers. - & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with + & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with * column 0 (1st col) if this is true. This is not documented. * * @return HTML @@ -2209,15 +2209,15 @@ return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,$compareFields0); } - + /** * Generate a SELECT tag string from a recordset, and return the string. - * If the recordset has 2 cols, we treat the 1st col as the containing + * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the SECOND column. * */ - function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') + function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') { include_once(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getmenu($this,$name,$defstr,$blank1stItem,$multiple, @@ -2232,10 +2232,10 @@ * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetArray($nRows = -1) + function &GetArray($nRows = -1) { global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows); - + $results = array(); $cnt = 0; while (!$this->EOF && $nRows != $cnt) { @@ -2245,7 +2245,7 @@ } return $results; } - + /* * Some databases allow multiple recordsets to be returned. This function * will return true if there is a next recordset, or false if no more. @@ -2254,61 +2254,61 @@ { return false; } - + /** - * return recordset as a 2-dimensional array. + * return recordset as a 2-dimensional array. * Helper function for ADOConnection->SelectLimit() * * @param offset is the row to start calculations from (1-based) * @param [nrows] is the number of rows to return * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetArrayLimit($nrows,$offset=-1) - { + function &GetArrayLimit($nrows,$offset=-1) + { if ($offset <= 0) { return $this->GetArray($nrows); - } - + } + $this->Move($offset); - + $results = array(); $cnt = 0; while (!$this->EOF && $nrows != $cnt) { $results[$cnt++] = $this->fields; $this->MoveNext(); } - + return $results; } - - + + /** * Synonym for GetArray() for compatibility with ADO. * * @param [nRows] is the number of rows to return. -1 means every row. * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetRows($nRows = -1) + function &GetRows($nRows = -1) { return $this->GetArray($nRows); } - + /** - * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. - * The first column is treated as the key and is not included in the array. + * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. + * The first column is treated as the key and is not included in the array. * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless * $force_array == true. * * @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, * read the source. * - * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and + * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and * instead of returning array[col0] => array(remaining cols), return array[col0] => col1 * - * @return an associative array indexed by the first column of the array, + * @return an associative array indexed by the first column of the array, * or false if the data has less than 2 cols. */ function &GetAssoc($force_array = false, $first2cols = false) { @@ -2318,7 +2318,7 @@ } $numIndex = isset($this->fields[0]); $results = array(); - + if (!$first2cols && ($cols > 2 || $force_array)) { if ($numIndex) { while (!$this->EOF) { @@ -2343,16 +2343,16 @@ while (!$this->EOF) { // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string $v1 = trim(reset($this->fields)); - $v2 = ''.next($this->fields); + $v2 = ''.next($this->fields); $results[$v1] = $v2; $this->MoveNext(); } } } - return $results; + return $results; } - - + + /** * * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format @@ -2368,8 +2368,8 @@ if ($tt == 0) return $this->emptyTimeStamp; return adodb_date($fmt,$tt); } - - + + /** * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() @@ -2385,74 +2385,74 @@ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } return adodb_date($fmt,$tt); - + } - - + + /** * @param $v is a date string in YYYY-MM-DD format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixDate($v) { - - if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; - + if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } - + /** * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixTimeStamp($v) { - - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; - + // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } - - + + /** * PEAR DB Compat - do not use internally */ function Free() { return $this->Close(); } - - + + /** * PEAR DB compat, number of rows */ function NumRows() { return $this->_numOfRows; } - - + + /** * PEAR DB compat, number of cols */ function NumCols() { return $this->_numOfFields; } - + /** - * Fetch a row, returning false if no more rows. + * Fetch a row, returning false if no more rows. * This is PEAR DB compat mode. * * @return false or array containing the current record @@ -2465,10 +2465,10 @@ if (!$this->_fetch()) $this->EOF = true; return $arr; } - - + + /** - * Fetch a row, returning PEAR_Error if no more rows. + * Fetch a row, returning PEAR_Error if no more rows. * This is PEAR DB compat mode. * * @return DB_OK or error object @@ -2480,26 +2480,26 @@ $this->MoveNext(); return 1; // DB_OK } - - + + /** * Move to the first row in the recordset. Many databases do NOT support this. * * @return true or false */ - function MoveFirst() + function MoveFirst() { if ($this->_currentRow == 0) return true; - return $this->Move(0); - } + return $this->Move(0); + } - + /** - * Move to the last row in the recordset. + * Move to the last row in the recordset. * * @return true or false */ - function MoveLast() + function MoveLast() { if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1); if ($this->EOF) return false; @@ -2511,14 +2511,14 @@ $this->EOF = false; return true; } - - + + /** * Move to next record in the recordset. * * @return true if there still rows available, or false if there are no more rows (EOF). */ - function MoveNext() + function MoveNext() { if (!$this->EOF) { $this->_currentRow++; @@ -2533,8 +2533,8 @@ } */ return false; - } - + } + /** * Random access to a specific row in the recordset. Some databases do not support * access to previous rows in the databases (no scrolling backwards). @@ -2543,15 +2543,15 @@ * * @return true if there still rows available, or false if there are no more rows (EOF). */ - function Move($rowNumber = 0) + function Move($rowNumber = 0) { $this->EOF = false; if ($rowNumber == $this->_currentRow) return true; if ($rowNumber >= $this->_numOfRows) if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; - - if ($this->canSeek) { - + + if ($this->canSeek) { + if ($this->_seek($rowNumber)) { $this->_currentRow = $rowNumber; if ($this->_fetch()) { @@ -2569,26 +2569,26 @@ adodb_movenext($this); } } else { - + while (! $this->EOF && $this->_currentRow < $rowNumber) { $this->_currentRow++; - + if (!$this->_fetch()) $this->EOF = true; } } return !($this->EOF); } - - $this->fields = false; + + $this->fields = false; $this->EOF = true; return false; } - - + + /** * Get the value of a field in the current row by column name. * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM. - * + * * @param colname is the field to access * * @return the value of $colname column @@ -2597,7 +2597,7 @@ { return $this->fields[$colname]; } - + function GetAssocKeys($upper=true) { $this->bind = array(); @@ -2607,7 +2607,7 @@ else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i; } } - + /** * Use associative array to get fields array for databases that do not support * associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it @@ -2619,45 +2619,45 @@ */ function GetRowAssoc($upper=1) { - + if (!$this->bind) { $this->GetAssocKeys($upper); } - + $record = array(); foreach($this->bind as $k => $v) { $record[$k] = $this->fields[$v]; } return $record; } - - + + /** * Clean up recordset * * @return true or false */ - function Close() + function Close() { // free connection object - this seems to globally free the object // and not merely the reference, so don't do this... - // $this->connection = false; + // $this->connection = false; if (!$this->_closed) { $this->_closed = true; - return $this->_close(); + return $this->_close(); } else return true; } - + /** - * synonyms RecordCount and RowCount + * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ function RecordCount() {return $this->_numOfRows;} - - + + /* * If we are using PageExecute(), this will return the maximum possible rows * that can be returned when paging a recordset. @@ -2666,54 +2666,54 @@ { return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount(); } - + /** - * synonyms RecordCount and RowCount + * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ - function RowCount() {return $this->_numOfRows;} - + function RowCount() {return $this->_numOfRows;} + /** * Portable RecordCount. Pablo Roca * * @return the number of records from a previous SELECT. All databases support this. * * But aware possible problems in multiuser environments. For better speed the table * must be indexed by the condition. Heavy test this before deploying. - */ + */ function PO_RecordCount($table="", $condition="") { - + $lnumrows = $this->_numOfRows; // the database doesn't support native recordcount, so we do a workaround if ($lnumrows == -1 && $this->connection) { IF ($table) { - if ($condition) $condition = " WHERE " . $condition; + if ($condition) $condition = " WHERE " . $condition; $resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition"); if ($resultrows) $lnumrows = reset($resultrows->fields); } } return $lnumrows; } - + /** * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function CurrentRow() {return $this->_currentRow;} - + /** * synonym for CurrentRow -- for ADO compat * * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function AbsolutePosition() {return $this->_currentRow;} - + /** * @return the number of columns in the recordset. Some databases will set this to 0 * if no records are returned, others will return the number of columns in the query. */ - function FieldCount() {return $this->_numOfFields;} + function FieldCount() {return $this->_numOfFields;} /** @@ -2723,23 +2723,23 @@ * * @return the ADOFieldObject for that column, or false. */ - function &FetchField($fieldoffset) + function &FetchField($fieldoffset) { // must be defined by child class - } - + } + /** * Get the ADOFieldObjects of all columns in an array. * */ function FieldTypesArray() { $arr = array(); - for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) + for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) $arr[] = $this->FetchField($i); return $arr; } - + /** * Return the fields array of the current row as an object for convenience. * The default case is lowercase field names. @@ -2750,11 +2750,11 @@ { return FetchObject(false); } - + /** * Return the fields array of the current row as an object for convenience. * The default case is uppercase. - * + * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row @@ -2775,16 +2775,16 @@ $name = $this->_names[$i]; if ($isupper) $n = strtoupper($name); else $n = $name; - + $o->$n = $this->Fields($name); } return $o; } - + /** * Return the fields array of the current row as an object for convenience. * The default is lower-case field names. - * + * * @return the object with the properties set to the fields of the current row, * or false if EOF * @@ -2794,12 +2794,12 @@ { return $this->FetchNextObject(false); } - - + + /** - * Return the fields array of the current row as an object for convenience. + * Return the fields array of the current row as an object for convenience. * The default is upper case field names. - * + * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row, @@ -2811,14 +2811,14 @@ { $o = false; if ($this->_numOfRows != 0 && !$this->EOF) { - $o = $this->FetchObject($isupper); + $o = $this->FetchObject($isupper); $this->_currentRow++; if ($this->_fetch()) return $o; } $this->EOF = true; return $o; } - + /** * Get the metatype of the column. This is used for formatting. This is because * many databases use different names for the same type, so we transform the original @@ -2829,8 +2829,8 @@ * fields bigger than a certain size as a 'B' (blob). * @param fieldobj is the field object returned by the database driver. Can hold * additional info (eg. primary_key for mysql). - * - * @return the general type of the data: + * + * @return the general type of the data: * C for character < 200 chars * X for teXt (>= 200 chars) * B for Binary @@ -2840,8 +2840,8 @@ * L for logical/Boolean * I for integer * R for autoincrement counter/integer - * * + * */ function MetaType($t,$len=-1,$fieldobj=false) { @@ -2890,7 +2890,7 @@ 'TIMESTAMPTZ' => 'T', 'T' => 'T', ## - 'BOOLEAN' => 'L', + 'BOOLEAN' => 'L', 'BIT' => 'L', 'L' => 'L', ## @@ -2919,62 +2919,62 @@ 'NUM' => 'N', 'NUMERIC' => 'N', 'MONEY' => 'N', - + ## informix 9.2 - 'SQLINT' => 'I', - 'SQLSERIAL' => 'I', - 'SQLSMINT' => 'I', - 'SQLSMFLOAT' => 'N', - 'SQLFLOAT' => 'N', - 'SQLMONEY' => 'N', - 'SQLDECIMAL' => 'N', - 'SQLDATE' => 'D', - 'SQLVCHAR' => 'C', - 'SQLCHAR' => 'C', - 'SQLDTIME' => 'T', - 'SQLINTERVAL' => 'N', - 'SQLBYTES' => 'B', - 'SQLTEXT' => 'X' + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X' ); - + $tmap = false; $t = strtoupper($t); $tmap = @$typeMap[$t]; switch ($tmap) { case 'C': - - // is the char field is too long, return as text field... + + // is the char field is too long, return as text field... if (!empty($this->blobSize)) { if ($len > $this->blobSize) return 'X'; } else if ($len > 250) { return 'X'; } return 'C'; - + case 'I': if (!empty($fieldobj->primary_key)) return 'R'; return 'I'; - + case false: return 'N'; - + case 'B': - if (isset($fieldobj->binary)) + if (isset($fieldobj->binary)) return ($fieldobj->binary) ? 'B' : 'X'; return 'B'; - + case 'D': if (!empty($this->dateHasTime)) return 'T'; return 'D'; - - default: + + default: if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B'; return $tmap; } } - + function _close() {} - + /** * set/returns the current recordset page when paginating */ @@ -2983,7 +2983,7 @@ if ($page != -1) $this->_currentPage = $page; return $this->_currentPage; } - + /** * set/returns the status of the atFirstPage flag when paginating */ @@ -2992,13 +2992,13 @@ if ($status != false) $this->_atFirstPage = $status; return $this->_atFirstPage; } - + function LastPageNo($page = false) { if ($page != false) $this->_lastPageNo = $page; return $this->_lastPageNo; } - + /** * set/returns the status of the atLastPage flag when paginating */ @@ -3008,18 +3008,18 @@ return $this->_atLastPage; } } // end class ADORecordSet - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet_array - //============================================================================================== - + //============================================================================================== + /** * This class encapsulates the concept of a recordset created in memory * as an array. This is useful for the creation of cached recordsets. - * + * * Note that the constructor is different from the standard ADORecordSet */ - + class ADORecordSet_array extends ADORecordSet { var $databaseType = 'array'; @@ -3041,41 +3041,41 @@ function ADORecordSet_array($fakeid=1) { global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH; - + // fetch() on EOF does not delete $this->fields $this->compat = !empty($ADODB_COMPAT_FETCH); - $this->ADORecordSet($fakeid); // fake queryID + $this->ADORecordSet($fakeid); // fake queryID $this->fetchMode = $ADODB_FETCH_MODE; } - - + + /** * Setup the Array. Later we will have XML-Data and CSV handlers * * @param array is a 2-dimensional array holding the data. - * The first row should hold the column names + * The first row should hold the column names * unless paramter $colnames is used. - * @param typearr holds an array of types. These are the same types + * @param typearr holds an array of types. These are the same types * used in MetaTypes (C,B,L,I,N). * @param [colnames] array of column names. If set, then the first row of * $array should not hold the column names. */ function InitArray($array,$typearr,$colnames=false) { $this->_array = $array; - $this->_types = $typearr; + $this->_types = $typearr; if ($colnames) { $this->_skiprow1 = false; $this->_colnames = $colnames; } else $this->_colnames = $array[0]; - + $this->Init(); } /** * Setup the Array and datatype file objects * * @param array is a 2-dimensional array holding the data. - * The first row should hold the column names + * The first row should hold the column names * unless paramter $colnames is used. * @param fieldarr holds an array of ADOFieldObject's. */ @@ -3085,10 +3085,10 @@ $this->_skiprow1= false; if ($fieldarr) { $this->_fieldobjects = $fieldarr; - } + } $this->Init(); } - + function &GetArray($nRows=-1) { if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) { @@ -3097,21 +3097,21 @@ return ADORecordSet::GetArray($nRows); } } - + function _initrs() { $this->_numOfRows = sizeof($this->_array); if ($this->_skiprow1) $this->_numOfRows -= 1; - + $this->_numOfFields =(isset($this->_fieldobjects)) ? sizeof($this->_fieldobjects):sizeof($this->_types); } - + /* Use associative array to get fields array */ function Fields($colname) { if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; - + if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -3121,8 +3121,8 @@ } return $this->fields[$this->bind[strtoupper($colname)]]; } - - function &FetchField($fieldOffset = -1) + + function &FetchField($fieldOffset = -1) { if (isset($this->_fieldobjects)) { return $this->_fieldobjects[$fieldOffset]; @@ -3131,10 +3131,10 @@ $o->name = $this->_colnames[$fieldOffset]; $o->type = $this->_types[$fieldOffset]; $o->max_length = -1; // length not known - + return $o; } - + function _seek($row) { if (sizeof($this->_array) && $row < $this->_numOfRows) { @@ -3143,32 +3143,32 @@ } return false; } - - function MoveNext() + + function MoveNext() { - if (!$this->EOF) { + if (!$this->EOF) { $this->_currentRow++; - + $pos = $this->_currentRow; if ($this->_skiprow1) $pos += 1; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; } else { $this->fields = $this->_array[$pos]; return true; - } + } $this->EOF = true; } - + return false; - } - + } + function _fetch() { $pos = $this->_currentRow; if ($this->_skiprow1) $pos += 1; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; return false; @@ -3177,44 +3177,44 @@ $this->fields = $this->_array[$pos]; return true; } - - function _close() + + function _close() { - return true; + return true; } - + } // ADORecordSet_array - //============================================================================================== + //============================================================================================== // HELPER FUNCTIONS - //============================================================================================== - + //============================================================================================== + /** * Synonym for ADOLoadCode. * * @deprecated */ - function ADOLoadDB($dbType) - { + function ADOLoadDB($dbType) + { return ADOLoadCode($dbType); } - + /** * Load the code for a specific database driver */ - function ADOLoadCode($dbType) + function ADOLoadCode($dbType) { GLOBAL $ADODB_Database; - + if (!$dbType) return false; $ADODB_Database = strtolower($dbType); switch ($ADODB_Database) { case 'maxsql': $ADODB_Database = 'mysqlt'; break; case 'postgres': case 'pgsql': $ADODB_Database = 'postgres7'; break; } - // Karsten Kraus - return @include_once(ADODB_DIR."/drivers/adodb-".$ADODB_Database.".inc.php"); + // Karsten Kraus + return @include_once(ADODB_DIR."/drivers/adodb-".$ADODB_Database.".inc.php"); } /** @@ -3224,7 +3224,7 @@ { return ADONewConnection($db); } - + /** * Instantiate a new Connection class for a specific database driver. * @@ -3236,18 +3236,18 @@ function &ADONewConnection($db='') { global $ADODB_Database; - + $rez = true; if ($db) { if ($ADODB_Database != $db) ADOLoadCode($db); - } else { + } else { if (!empty($ADODB_Database)) { ADOLoadCode($ADODB_Database); } else { $rez = false; } } - + $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; if (!$rez) { if ($errorfn) { @@ -3257,32 +3257,32 @@ $dbtype); } else ADOConnection::outp( "

ADONewConnection: Unable to load database driver '$db'

",false); - + return false; } - + $cls = 'ADODB_'.$ADODB_Database; $obj = new $cls(); if ($errorfn) $obj->raiseErrorFn = $errorfn; - + return $obj; } - + function &NewDataDictionary(&$conn) { $provider = $conn->dataProvider; $drivername = $conn->databaseType; - if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado') + if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado') $drivername = $conn->dataProvider; else { if (substr($drivername,0,5) == 'odbc_') $drivername = substr($drivername,5); else if (substr($drivername,0,4) == 'ado_') $drivername = substr($drivername,4); - else + else switch($drivername) { case 'oracle': $drivername = 'oci8';break; case 'sybase': $drivername = 'mssql';break; case 'access': - case 'db2': + case 'db2': break; default: $drivername = 'generic'; @@ -3305,7 +3305,7 @@ $dict->upperName = strtoupper($drivername); if (is_resource($conn->_connectionID)) $dict->serverInfo = $conn->ServerInfo(); - + return $dict; } @@ -3314,11 +3314,11 @@ * Save a file $filename and its $contents (normally for caching) with file locking */ function adodb_write_file($filename, $contents,$debug=false) - { + { # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows # So to simulate locking, we assume that rename is an atomic operation. - # First we delete $filename, then we create a $tempfile write to it and - # rename to the desired $filename. If the rename works, then we successfully + # First we delete $filename, then we create a $tempfile write to it and + # rename to the desired $filename. If the rename works, then we successfully # modified the file exclusively. # What a stupid need - having to simulate locking. # Risks: @@ -3328,13 +3328,13 @@ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated if (strpos(strtoupper(PHP_OS),'WIN') !== false) { // skip the decimal place - $mtime = substr(str_replace(' ','_',microtime()),2); + $mtime = substr(str_replace(' ','_',microtime()),2); // unlink will let some latencies develop, so uniqid() is more random @unlink($filename); // getmypid() actually returns 0 on Win98 - never mind! $tmpname = $filename.uniqid($mtime).getmypid(); if (!($fd = fopen($tmpname,'a'))) return false; - $ok = ftruncate($fd,0); + $ok = ftruncate($fd,0); if (!fwrite($fd,$contents)) $ok = false; fclose($fd); chmod($tmpname,0644); @@ -3357,23 +3357,23 @@ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
\n"); $ok = false; } - + return $ok; } - + function adodb_backtrace($print=true) { $s = ''; if (PHPVERSION() >= 4.3) { - + $MAXSTRLEN = 64; - + $s = '
';
 			$traceArr = debug_backtrace();
 			array_shift($traceArr);
 			$tabs = sizeof($traceArr)-1;
-			
+
 			foreach ($traceArr as $arr) {
 				$args = array();
 				for ($i=0; $i < $tabs; $i++) $s .= '   ';
@@ -3386,7 +3386,7 @@
 					else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
 					else if (is_object($v)) $args[] = 'Object:'.get_class($v);
 					else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
-					else { 
+					else {
 						$v = (string) @$v;
 						$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
 						if (strlen($v) > $MAXSTRLEN) $str .= '...';
@@ -3397,12 +3397,12 @@
 				$s .= @sprintf(" # line %4d, file: %s",
 					$arr['line'],$arr['file'],$arr['file']);
 				$s .= "\n";
-			}	
+			}
 			$s .= '
'; if ($print) print $s; } return $s; } - + } // defined ?> \ No newline at end of file Index: trunk/kernel/include/modules.php =================================================================== diff -u -N -r8029 -r8436 --- trunk/kernel/include/modules.php (.../modules.php) (revision 8029) +++ trunk/kernel/include/modules.php (.../modules.php) (revision 8436) @@ -967,7 +967,6 @@ /*create the global current user object */ $UserID=$objSession->Get("PortalUserId"); $objCurrentUser = new clsPortalUser($UserID); -$objLanguageCache = new clsLanguageCache($m_var_list["lang"]); /* include each module's action.php script */ LogEntry("Loading Module action scripts\n"); Index: trunk/kernel/include/error.php =================================================================== diff -u -N -r3282 -r8436 --- trunk/kernel/include/error.php (.../error.php) (revision 3282) +++ trunk/kernel/include/error.php (.../error.php) (revision 8436) @@ -4,7 +4,7 @@ { var $m_Message; var $m_Field; - + function clsError($message,$field) { $this->SetMessage($message); @@ -15,25 +15,25 @@ { return $this->m_Message; } - - function SetMessage($value) + + function SetMessage($value) { $this->m_Message = $value; } - - function GetField() + + function GetField() { return $this->m_Field; } - - function SetField($value) + + function SetField($value) { $this->m_Field = $value; } - + } -class clsErrorManager +class clsErrorManager { var $m_errorsMap = array(); @@ -61,7 +61,7 @@ { return $this->config[$property]; } - + function Set($property, $value) { $varname = "m_".$property; @@ -70,7 +70,7 @@ function ClearErrors() - { + { unset($this->m_Errors); $this->m_CurrentError = 0; $this->m_UserErrors = array(); @@ -80,26 +80,26 @@ { $this->m_Language=$lang; } - + function AddAdminUserError($errorLang) { $this->m_UserErrors[] = $errorLang; } - + function GetAdminUserErrors() { return $this->m_UserErrors; - } + } function AddError($errorPhrase, $errorField=NULL,$arg1 = NULL,$arg2 = NULL,$arg3 = NULL,$arg4 = NULL,$fatal=FALSE) { - global $g_DebugMode, $objLanguageCache, $g_ErrorLog; - - + global $g_DebugMode, $g_ErrorLog; + + $errorText = ""; //$arg3::$arg4\t$errorPhrase\t$arg1 #arg2 - $errorText = "%s::%s\t%s\t%s %s\n"; + $errorText = "%s::%s\t%s\t%s %s\n"; $errorMessage = sprintf($errorText,$arg3,$arg4,$errorPhrase,$arg1,$arg2); $error = new clsError($errorMessage, $errorField); @@ -130,7 +130,7 @@ else { return ""; - } + } } function GetNextError() @@ -143,7 +143,7 @@ return FALSE; } - + function HandleErrors($postBackUrl) { @@ -191,9 +191,9 @@ function Permission_Error($message) -{ +{ global $PermissionError; - + $PermissionError = $message; /* here we can do some logging or other cool stuff */ } Index: trunk/core/kernel/db/db_connection.php =================================================================== diff -u -N -r8104 -r8436 --- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8104) +++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8436) @@ -13,23 +13,23 @@ * @access private */ var $dbType = 'mysql'; - + /** * Created connection handle * * @var resource * @access private */ var $connectionID = null; - + /** * Handle of currenty processed recordset * * @var resource * @access private */ var $queryID = null; - + /** * DB type specific function mappings * @@ -53,7 +53,7 @@ * @access private */ var $errorCode = 0; - + /** * Error message * @@ -77,7 +77,7 @@ * @var string */ var $lastQuery = ''; - + /** * Initializes connection class with * db type to used in future @@ -157,7 +157,7 @@ /*if (!isset($this->metaFunctions[$name])) { $this->metaFunctions[$name] = $name; }*/ - + return $this->dbType.'_'.$name; } @@ -402,7 +402,7 @@ } // set 2nd checkpoint: begin if(!$isSkipTable) { - $debugger->profileFinish('sql_'.$queryID); + $debugger->profileFinish('sql_'.$queryID, null, null, $this->getAffectedRows()); $debugger->profilerAddTotal('sql', 'sql_'.$queryID); } $this->Destroy(); @@ -412,7 +412,7 @@ else { // set 2nd checkpoint: begin if(!$isSkipTable) { - $debugger->profileFinish('sql_'.$queryID); + $debugger->profileFinish('sql_'.$queryID, null, null, $this->getAffectedRows()); $debugger->profilerAddTotal('sql', 'sql_'.$queryID); } // set 2nd checkpoint: end @@ -572,7 +572,7 @@ return $this->ChangeQuery($sql); } - + /** * Allows to detect table's presense in database * @@ -582,15 +582,15 @@ function TableFound($table_name) { static $table_found = Array(); - + if (!preg_match('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', $table_name)) { $table_name = TABLE_PREFIX.$table_name; } - + if (!isset($table_found[$table_name])) { $table_found[$table_name] = $this->Query('SHOW TABLES LIKE "'.$table_name.'"'); } - + return $table_found[$table_name]; } }