0

我需要帮助来理解以下代码。我想知道的是 set_query($data,$limit_enable) 中的代码行。如果对此事有任何帮助,我们将不胜感激。

function get_data($data){

    $out = array();
    $this->set_query($data,$limt_enabled);
    //some code
}

function set_query($data,$limit_enable){

    $data['selection'] =  isset($data['selection'])? $data['selection']: 'task_master.staff_id,staff.full_name,creator_staff.full_name AS creator' ;
    //some code
 }
4

1 回答 1

1

实际上$this->set_query($data,$limt_enabled);是调用set_query()同一个类的方法,并且set_query()有一个三元表达式,即

$data['selection'] =  isset($data['selection'])? $data['selection']: 'task_master.staff_id,staff.full_name,creator_staff.full_name AS creator' ;

它的意思是

if( isset($data['selection']) )
{
    $data['selection'] = $data['selection'];
}
else
{
    $data['selection'] = 'task_master.staff_id,staff.full_name,creator_staff.full_name AS creator'
}

我不确定你是从哪里framework得到它的,但看起来像这样,如果尚未$data['selection']设置从表中选择,则设置选择标准,例如

select task_master.staff_id, staff.full_name, creator_staff.full_name

这实际上将用于选择一些表字段,这些是

 staff_id field from table `task_master
 full_name field from table `staff
 full_name field from table `creator_staff

它还为此选择设置别名 AS creator

于 2013-06-25T02:10:20.277 回答