Join the forums now, and start posting to receive access to our Scripts Vault!
public function login($id, $application_object, $error_object, $db_object...)
$smarty->assign("variable1", $variable1);$smarty->assign("variable2", $variable2);$smarty->assign("variable3", $variable3);...
foreach($GLOBALS as $varname => $variable) global $$varname;
function __autoload($function){ if( file_exists(R."/objects/$function.php") ) require_once R."/objects/$function.php"; else die( "Autoload: Missing class file" );}
function __autoload($function){ @require_once R."/objects/$function.php"; if(!$file_loaded) die( "Autoload: Missing class file" );}
$file_loaded = @require_once "...";if(!$file_loaded)...
$bar is the value 1 because the include was successful. Notice the difference between the above examples. (...) . If the file can't be included, FALSE is returned and E_WARNING is issued.
/** * Used to buy peons. * @param int $peons Contains the number of peons that the user wants. */function buyPeons($peons){ $cost = (50 * $peons); // Check to see if we have enough gold if ($cost > $_SESSION['gold']) return false; // Check to see if were below our maximum peon count if (($_SESSION['peons']+$peons) > 100) return false; $_SESSION['gold'] -= $cost; $_SESSION['peons'] += $peons; return true;}
/** * Used to buy peons. * @param int $peons Contains the number of peons that the user wants. */function buyPeons($peons){ $cost = (50 * $peons); // Check to see if we have enough gold if ($cost > $_SESSION['gold']) throw new Exception('Your to poor'); // Check to see if were below our maximum peon count if (($_SESSION['peons']+$peons) > 100) throw new Exception('You already have to many peons'); $_SESSION['gold'] -= $cost; $_SESSION['peons'] += $peons; return true;}//usagetry { buyPeons(150);} catch(Exception $e) { echo 'It looks like you cannot buy any more peons, because "'+$e.getMessage()+'".';}
try { MoneyObject::spend(150);} catch (Database_Exception $e){ // We want to send our admin a message telling them something is wrong with the database. mail(...); // Other work that needs to happen to make sure the database falling over doesn't effect the user to much...} catch (Money_Exception $e){ echo 'It looks like you maybe far to poor to spend the amount you wanted';} catch (Exception $e){ echo 'Something random went wrong, sorry about that...';}
Thank you ... I might even have one at home, will take a look
Well... I heard that @ is not that efficient either and I guess the second file check would be faster ...?
<?php $this->db->query("...")?>
<?php $this->dbp->write->query("...")?>
<?php$this->dbp->write->query("insert into table...");$this->dbp->write->query("update table...");$this->dbp->read->fetchAll("select name, login, password from users...");$this->dbp->read->result("select count(*) from table");$this->dbp->system->query(/* dump db into file */);$this->dbp->system->query(/* create trigger */);// etc...?>
Likely, you have an infrastructure setup with a group of master databases (for redundancy in case of fail-over) which are slaved out to read-only databases on each application server.
I'm feeling dumber with every passed day so please have patience with me
QuoteLikely, you have an infrastructure setup with a group of master databases (for redundancy in case of fail-over) which are slaved out to read-only databases on each application server.Sounds like I'd have like 8 database servers though currently I might afford one all-purpose VPS at best I know... I should have it flexible and I'm rather perfectionist myself, just sayin'...
Code: [Select]function __autoload($function){ @require_once R."/objects/$function.php"; if(!$file_loaded) die( "Autoload: Missing class file" );}And put $file_loaded=1; at the beginning of each file.
function __autoload($class) { @require_once R."/objects/$class.php"; if (!class_exists($class)) trigger_error("Autoload: tried to load $class.");}