Skip to content

Instantly share code, notes, and snippets.

<?php
function saveCacheFile($file, $contents)
{
$serialized = serialize($contents);
$len = strlen($serialized);
$cachefile_fp = @fopen($file, 'xb'); // x is the O_CREAT|O_EXCL mode
if ($cachefile_fp !== false) { // create file
if (fwrite($cachefile_fp, $serialized, $len) < $len) {
return PEAR::raiseError("Could not write $file.");
<?php
class DatabaseStatementBase extends PDOStatement {
public $dbh;
protected function __construct($dbh) {
$this->dbh = $dbh;
$this->setFetchMode(PDO::FETCH_OBJ);
}
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
<?php
class DatabaseStatementBase extends PDOStatement {
public $dbh;
protected function __construct($dbh) {
$this->dbh = $dbh;
$this->setFetchMode(PDO::FETCH_OBJ);
}
}
static __inline void do_cpuid(u_int ax, u_int *p) {
__asm __volatile("pushl %%ebx\n\t"
"cpuid\n\t"
"movl %%ebx, %%esi\n\t"
"popl %%ebx\n\t"
: "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3])
: "a" (ax));
}