oid vs bytea in Postgresql

Okay, here is the deal, I am working on a project which requires me to store files in my database. But I have recently just switched to postgresql from mysql, so I had to do some research on what methods postgresql offers for file storage. In mysql GLOB would have been my choice, but postgresql offers two methods, BYTEA which is postgresql’s answer to GLOB, or store the files in Large Objects (oid).

I asked around to find out what method would be the fastes, but I could not find the answer I was looking for, so I ended up spending the night testing it for myself, this blog will show the results.

Læs videre “oid vs bytea in Postgresql”

Safe Email function

This should be a spambot safe way to return emails out on a webpage, it prints the email out with javascript with random substrings.

function InsertMail($mail) {
if ($mail=='') return '';
$mail = str_replace(array('@',':','.'), array('@',':','.'), $mail);
$len = strlen($mail);
$i=0;
while($i< $len) {
$c = mt_rand(1,4);
$par&#91;&#93; = (substr($mail, $i, $c));
$i += $c;
}
$join = implode('"+ "', $par);
return '<script language="javascript">
<!--
document.write("'.$join.'")
//-->
';
}

Source: http://dk2.php.net/manual/da/function.htmlentities.php#76049

Optimize PHP and Accelerate Apache

As the load on an application increases, the bottlenecks in the underlying infrastructure become more apparent in the form of slow response to user requests. This article discusses many of the server configuration items that can make or break an application’s performance and focuses on steps you can take to optimize Apache and PHP.

read more | digg story