Two very interesting reads

Labels: mysql, performance

Labels: mysql, performance
Stéphane Thomas, from Simple Entrepreneur, has gathered a bunch of slideshares from people around town that have worked on scaling web applications:
Labels: mysql, performance, php
I've created a mediawiki extension that mimics Trac's ability to follow the progression of a Bugzilla milestone. All you have to do is put some bugs in a milestone, then put a tag in your wiki page with the name of the milestone, and you get a nice clickable progress bar with the bugs that are open or not: http://www.mediawiki.org/wiki/Extension:BugMilestone
MDB2 is a PEAR package that performs some abstraction on the native PHP DB calls. In short, it allows to use $DB->query($sql) instead of mysql_query or mssql_query (plus a few more things).
ISNULL(somefield) should be somefield IS NULL. That's the ANSI way and ISNULL won't work on MS SQL...date('Y-m-d H:i:s')INSERT INTO my_table (id, name) VALUES (NULL, 'first');
$values = array();
$values['name'] = $GLOBALS['mdb2']->quote("first");
$newId = $GLOBALS['mdb2']->extended->getBeforeID('my_table', 'id', true, true);
if($newId != 'NULL')
$values['id'] = $newId;
$sql = "INSERT INTO my_table (".implode(',', array_keys($values)).") ".
" VALUES (" . implode(',', $values) . ")";
$result = $GLOBALS['mdb2']->query($sql);
if (EpiDBTools::IsMDB2Error($result))
return false;
$newId = $GLOBALS['mdb2']->extended->getAfterID($newId, 'my_table', 'id');
if (PEAR::isError($newId))
{
$newId = false;
return false;
}
if ($GLOBALS['mdb2']->dbsyntax == 'mssql')
{
// On MS SQL, allow temporarilly to insert a row by specifying the id
$result = $GLOBALS['mdb2']->query('SET IDENTITY_INSERT my_table ON');
if (PEAR::isError($result))
return false;
}
$sql = "INSERT INTO my_table (id, name) VALUES (4, 'first')";
$result = $GLOBALS['mdb2']->query($sql);
if (PEAR::isError($result))
return false;
if ($GLOBALS['mdb2']->dbsyntax == 'mssql')
{
$result = $GLOBALS['mdb2']->query('SET IDENTITY_INSERT my_table OFF');
if (PEAR::isError($result))
return false;
}
In any big enough PHP application, comes a time when some of the objects that are used in the application might be overriden by some extensions, to customize the functionnality of the application.
class LDAP_Employee extends Employee
{
function LDAP_Employee($id)
{
$this->Employee($id);
}
// Some more code to deal with the LDAP directory ...
// ...
}$GLOBALS['ClassDefinitions']['Employee'] = 'Employee'; // Name of the original class$MyEmployee = new $GLOBALS['ClassDefinitions']['Employee']($MyId);$GLOBALS['ClassDefinitions']['Employee'] = 'LDAP_Employee'; // Now we'll use the overriden class everywhere