I have a public function inside a class as follows
class View{
public function getVideoTitle($video_id)
{
$sql = 'SELECT video_title FROM '.$this->CFG['db']['tbl']['video'].
' WHERE video_id='.$this->dbObj->Param('video_id');
$stmt = $this->dbObj->Prepare($sql);
$rs = $this->dbObj->Execute($stmt, array($video_id));
if (!$rs)
trigger_error($this->dbObj->ErrorNo().' '.$this->dbObj->ErrorMsg(), E_USER_ERROR);
if($row = $rs->FetchRow())
return $row['video_title'];
return;
}
}
I can echo out the value of the function by doing
echo View::getVideoTitle(375) //where 375 is the id of the video
My question is how can i use the same function getVideoTitle() to also retrieve other fields in the database and not just title.
If i do let’s say $sql = 'SELECT * FROM.... what should i return in the function and how do use the function to echo out a certain field of this sql statement.
Try this.