I would like to pass two parameters to a SELECT query for one scenario in a vtiger custom function. Like below ..
function start_date($projectid, $stage){
$adb = PearDatabase::getInstance();
$stage = "Stage-0";
$data = $adb->pquery("SELECT startdate FROM vtiger_projecttask WHERE projectid = ?", array($projectid), array($stage);
$num_rows = $adb->num_rows($data);
for($i=0; $i<$num_rows; $i++) {
$col3[$i] = $adb->query_result($data, $i,'startdate');
}
}
But it is not allowing me to execute this type of query. How can i form a query with two parameters in vtiger?
Thanks and Regards.
Please try this code as below. This will work.
function start_date($projectid, $stage){
$adb = PearDatabase::getInstance();
$stage = "Stage-0";
$data = $adb->pquery("SELECT startdate FROM vtiger_projecttask WHERE projectid = ? and stage = ?", array($projectid,$stage));
$num_rows = $adb->num_rows($data);
for($i=0; $i<$num_rows; $i++) {
$col3[$i] = $adb->query_result($data, $i,'startdate');
}
}