0

i'm using Joomla! 2.5 and i'm trying to pass a variable from a public function to a protected function inside the same class but something I'm doing wrong. Any idea what is it?

    public function getJobsType() {     

    $jobsquery = $db->getQuery(true);
    // Select the records for the connected user
    $jobsquery = "SELECT jobassigned FROM #__jobs_userac WHERE user =".$userId;
    $db->setQuery($jobsquery);
    $row = $db->loadRowList();
    // I have one row per user so it returns only one field
    $job_id = $row['0']['0'];
    return $job_id;}


    protected function getListQuery() {

    //If i set the variable values my self  the query is working
   // ex. $job_id ="1,2,3";

   $db = $this->getDbo();
   $query = $db->getQuery(true);


   $query ->select($this->getState('list.select', 'DISTINCT a.*'));
   $query->from('`#__jobs_data` AS a');

   // I want to pass the values from the getJobsType() here
   $query->where('type IN ('.$job_id.')');


        ................

Thanks in advance for any help you are able to provide.

Chris
  • 45
  • 7

1 Answers1

0

Based on the comments, your problem is that you're not actually passing anything to your protected function. So pass the job_id by value as follows:

return getListQuery($job_id);

And change your function definition to:

protected function getListQuery($job_id) {

There are multiple ways to solve your problem, but this seems to be the most direct way.

Leo Bedrosian
  • 3,659
  • 2
  • 18
  • 22