php » Enta

Mod re write friendly

function reWrite($str)
{
$str = str_replace(” “, “-”, $str);// replace spaces
$str = str_replace(”&”, “and”, $str); //replace ampersands
$str = str_replace(”/”, “–”, $str); //replace slashes
$str = ereg_replace(”[^A-Za-z0-9-]“, “”, $str);// replace non alpha characters
return $str;
}

Posted by Mark on April 18th, 2009 under Enta  •  No Comments

DB Query

$query=”select * from table WHERE id=$id”;
$db = new DB();
if (!$db->open()){
die($db->error());
}
if (!$this->db->query($query)){
trigger_error($this->db->error(), E_USER_ERROR);
die(”Database Error”);
}
if($db->numRow()){
while($row=$db->fetchAssoc()){
//do stuff
}
}
$last_inserted_id=$db->getID();

Posted by Mark on April 17th, 2009 under Enta  •  No Comments