Class creation fail check... help please!
Posted: Fri Nov 07, 2008 5:54 pm
I run this class:
Which I want to run like this so that it returns false if $num does not == 1:
Any ideas?
Code: Select all
class Clan {
public $info = array();
function Clan($id) {
global $App;
$sql = "SELECT * FROM `clan` WHERE `clan_id` = '$id' LIMIT 1";
$result = $App->query($sql);
$num = mysql_num_rows($result);
if($num == 1){
$row = mysql_fetch_array($result);
$this->info = $row;
}
else{
$this = NULL; // returns an error
unset($this); // doesnt work
}
}
}Code: Select all
if($aClan = new Clan($cid)){
// stuff goes here
}