我有以下课程,我在其中添加了 property $user
。
include_once(__CA_LIB_DIR__."/ca/Search/BaseSearch.php");
include_once(__CA_LIB_DIR__."/ca/Search/ObjectSearchResult.php");
class ObjectSearch extends BaseSearch {
# ----------------------------------------------------------------------
/**
* Which table does this class represent?
*/
protected $ops_tablename = "ca_objects";
protected $ops_primary_key = "object_id";
public $user;
# ----------------------------------------------------------------------
public function &search($ps_search, $pa_options=null, $user) {
return parent::doSearch($ps_search, new ObjectSearchResult(), $pa_options);
}
# ----------------------------------------------------------------------
}
?>
在下面的代码中,我无法将$user
属性传递给 search 方法。我试过$user
,$this->user
和new ObjectSearch($user)
。作为 PHP 新手,我知道我在问一个幼稚的问题,但我自己无法解决,相信我已经尝试了好几天。我怎样才能做到这一点?
$po_request = $this->getVar('request');
$vs_widget_id = $this->getVar('widget_id');
$user = $this->getVar('user');
$o_search = new ObjectSearch();
$result = $o_search->search('created.$user.:"2013"');
$count = 1;
while($result->nextHit()) {
print "Hit ".$count.": "."<br/>\n";
print "Idno: ".$result->get('ca_objects.idno')."<br/>\n";
print "Name: ".$result->get('ca_objects.preferred_labels.name')."<br/>\n";
$count++;
}
?>