pIsConnected = true; $this->pResourceLink = mysql_connect($this->pHost, $this->pUser, $this->pPassword); if (!$this->mNoError()) { $this->pIsConnected = false; $tmpOutput = false; } return $tmpOutput; } function mSelect() { mysql_select_db($this->pDatabase, $this->pResourceLink); $this->mExecuteQuery("SET NAMES utf8"); return $this->mNoError(); } // MySQL 4.0> gets the total amount of rows without the limit x,y function mGetFoundRows() { $tmpSQL = "SELECT FOUND_ROWS() AS total_rows"; $result = mysql_query($tmpSQL, $this->pResourceLink); $tmpRecordA = mysql_fetch_array($result, MYSQL_ASSOC); return $tmpRecordA['total_rows']; } // private function mNoError() { $tmpOutput = true; //default true, otherwise when error occurs: false if (mysql_errno($this->pResourceLink)>0) { $this->pOperationOutput .= mysql_errno($this->pResourceLink) . ": " . mysql_error($this->pResourceLink) . "
"; $tmpOutput = false; } return $tmpOutput; } function mCleanStringForDb($stringIn) { $stringIn = trim($stringIn); if ((substr($stringIn,0,1) == "\"") && (substr($stringIn,-1,1) == "\"")) { $stringIn = trim($stringIn); $stringIn = substr($stringIn,1,strlen($stringIn)-2); if (substr($stringIn,-2) == "\"\"") { $stringIn = substr($stringIn,0,strlen($stringIn)-1); } } return addslashes($stringIn); } // function added 23 nov 2006 function mGetInsertId() { return mysql_insert_id ($this->pResourceLink); } // function added 3 dec 2006 function mGetNumRows() { return $this->pNumRows; } // function added 12 mei 2006 function mExecuteQuery($SQLIn) { $this->pLastQuery = $SQLIn; $result = mysql_query($this->pLastQuery,$this->pResourceLink); $this->pRecordsInResult = Array(); if (mysql_errno($this->pResourceLink)>0) { $this->pError = true; print "
";
                                        print $this->mGetErrorInfo();
                                        print "
"; } else { $this->pError = false; while (@$tmpRecordA = mysql_fetch_array($result, MYSQL_ASSOC)) { $this->pRecordsInResult[] = $tmpRecordA; } if (strpos(strtolower($SQLIn), "select ") !== false ) { $this->pNumRows = mysql_num_rows($result); //if ($this->pNumRows) echo $SQLIn."
"; } } @mysql_free_result($result); return $this->pRecordsInResult; } function mGetErrorInfo() { return mysql_errno($this->pResourceLink) . ": " . mysql_error($this->pResourceLink) . " query:".$this->pLastQuery."
"; } /* Generereer Uniek HashId */ function CreateHashId($RandNumber) { $tmpDate = date('D dS M,Y h:i:s a'); $tmpMicrotimeFloat = microtime(true); $tmpDateThing =$tmpDate.$tmpMicrotimeFloat; $this->HashId = md5($tmpDateThing.$RandNumber); return $this->HashId; } // function door Edgar op 03.07.2008: deze functie bepaald of een bepaald veld in de tabel aanwezig is. function doesFieldExist($tableNameIn,$fieldNameIn) { $fields = mysql_list_fields($this->pDatabase, $tableNameIn); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) {$field_array[] = mysql_field_name($fields, $i);} if (in_array($fieldNameIn, $field_array)) { return true; } else { return false; } } function escape($string) { if ($GLOBALS['dbserver'] == 'mssql') { return eregi_replace("'","''",$string); } if ($GLOBALS['dbserver'] == 'mysql') { return addslashes($string); } } } ?> pDBO = new dbClass(); $this->pDBO->mConnect(); $this->pDBO->mSelect(); } function mGetSmarty() { $tmpSmartyO = new Smarty(); $tmpSmartyO->template_dir = SITE_BASE.'smarty/templates'; $tmpSmartyO->compile_dir = SITE_BASE.'smarty/templates_c'; $tmpSmartyO->cache_dir = SITE_BASE.'smarty/cache'; $tmpSmartyO->config_dir = SITE_BASE.'smarty/configs'; return $tmpSmartyO; } /* function : mRender */ /* By: Tobias Beuving */ /* function to render one record a a time */ function mRender($recordIn = null,$templateIn, $forceArrayAsValueIn = false) { foreach($recordIn AS $key=>$value) { if (is_array($value) && !$forceArrayAsValueIn) { print "Error: baseClass.mRender: trying to render data with template:".$templateIn; print "
"; print "recordIn is array with multiple records, use baseClass.mRenderMultiple"; print "
"; print "RecordIn
"; print "
";
                                        print_r($recordIn);
                                        print "
"; print "Halted at key:".$key." value:"; print "
";
                                        print_r($value);
                                        print "
"; exit; } } $tmpHTML = ""; if ($recordIn == 0) { $recordIn = Array(); } $tmpSmartyO = baseClass::mGetSmarty(); foreach($recordIn AS $key=>$value) { $tmpSmartyO->assign($key, $value); } return $tmpSmartyO->fetch($templateIn); } /* function : mRenderMultiple */ /* By: Tobias Beuving */ /* function to render records with each there own template */ function mRenderMultiple($recordsIn = null,$templateIn) { if ($recordsIn == null) { $recordsIn = Array(); } $tmpHTML = ""; foreach($recordsIn AS $tmpRecord) { $tmpSmartyO = baseClass::mGetSmarty(); foreach($tmpRecord AS $key=>$value) { $tmpSmartyO->assign($key, $value); } $tmpHTML .= $tmpSmartyO->fetch($templateIn); } return $tmpHTML; } /* function : mRenderMore */ /* By: Edgar Vijgeboom */ /* function to render all records in one go to Array, use it for having more SQL records in one template */ function mRenderMore($recordsIn = null,$templateIn) { if ($recordsIn == null) { $recordsIn = Array(); } $tmpHTML = ""; $tmpSmartyO = baseClass::mGetSmarty(); $tmpSmartyO->assign("result", $recordsIn); $tmpHTML .= $tmpSmartyO->fetch($templateIn); return $tmpHTML; } /* * Creates and appends a text node with value to a DOM document * * @param $nameIn String name of the tag * @param $valueIn String value of the tag * @param $domDocIn String dom document, passed by reference * @param $nodeIn String dom-node-element, passed by reference * * @returns nothing, objects are passed by reference */ function _mCreateAndAppendTextNode(&$domDocIn, &$nodeIn, $nameIn, $valueIn) { $tmpElement = $domDocIn->createElement($nameIn); $tmpElement->appendChild($domDocIn->createTextNode($valueIn)); $nodeIn->appendChild($tmpElement); } /* function : mArrayToJSON */ /* By: Tobias Beuving */ /* maakt een JSON (Javascript object notation) string van een array */ function mArrayToJSON($tmpArrayIn) { $tmpRecords = Array(); foreach ($tmpArrayIn AS $key=>$value) { $tmpValueString = ""; if (is_array($value)) { $tmpPropertiesB = Array(); foreach ($value AS $key2=>$value2) { $tmpPropertiesB[] = '"'.$key2.'": "'.str_replace(chr(13).chr(10), '', addslashes($value2)).'"'; } $tmpValueString = "{".implode(",", $tmpPropertiesB)."}"; } else { $tmpValueString = '"'.nl2br($value).'"'; } //$tmpPropertiesA[] = '"'.$key.'": '.$tmpValueString; $tmpRecords[] = $tmpValueString; } $tmpPropertiesString = implode(",", $tmpRecords); $tmpJSON = '['. $tmpPropertiesString . ']'; return $tmpJSON; } } ?>