1

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.

Jaccs
  • 1,052
  • 3
  • 12
  • 33
  • Answer which i have given is the perfect as per your question. Can you please tell what you exactly required if you doesn't get your solution so i can update my answer – Milan Malani Oct 01 '16 at 12:48

1 Answers1

2

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');      
    }
}
Milan Malani
  • 1,818
  • 1
  • 22
  • 34