I have a function like below:
public function select($id=null) {
$query = "select * from press_releases where id = {$id}";
$results = $this->db->query($query);
return $results;
}
If no $id is specified during function invoke, I want to return all the records but I think NULL default value is not a good option for that. What should I do instead of NULL to retrieve all the records other than using a another query which doesn’t specify the id field in the where section.
Thanks…
If
$idis an integer, I would use:Either way I would make sure
$idis safe to use.