function LookupByPid($pid) { $safe_pid = addslashes($pid); $query_result = DBQueryWarn("select pid_idx from projects where pid='{$safe_pid}'"); if (!$query_result || !mysql_num_rows($query_result)) { return null; } $row = mysql_fetch_array($query_result); $idx = $row['pid_idx']; $foo = new Project($idx); if ($foo->IsValid()) { return $foo; } return null; }