0
我使用Joomla! 2.5,我試圖將一個公共函數的變量傳遞給同一個類中的受保護的函數,但是我做錯了。任何想法是什麼?將變量從一個函數傳遞到另一個函數php
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.')');
................
在此先感謝您提供的任何幫助。
那麼你在哪裏試圖傳遞一個變量? – 2014-09-22 18:35:56
from getJobsType()getListQuery()作爲變量$ job_id – Chris 2014-09-22 18:36:40
它只是我,還是你沒有實際調用getJobsType? – WreithKassan 2014-09-22 18:37:21