我有一段代码,我从 SQL 中获取多行数据,并且在其中一列中有一个数值,如果它等于某个数字,我需要检查并将数据更改为文本。为了做到这一点,我需要知道数组元素是如何命名$results[????]
的,以便获取并更改它。那么在使用 SQL/Cake 时,数组的命名约定是什么?
这是结块的代码:
$params = array(
'fields' => array(
$this->name . '.AUTHORIZE_PROVIDER_NAME',
$this->name . '.SOURCE_ID',
$this->name . '.ORDER_ITEM_TITLE',
$this->name . '.DOSE_AMOUNT',
$this->name . '.DOSE_UNIT',
$this->name . '.DT_CREATED_TIME',
$this->name . '.ROUTE_ID',
$this->name . '.SEQUENCE_NO',
$this->name . '.LOCATION',
$this->name . '.BODY_SITE_ID',
$this->name . '.COMMENT',
'DD.DICTIONARY_DATA_CODE',
),
/*
'conditions' => array(
//conditions
$this->name . '.HID' => $hospital_id,
$this->name . '.PID' => $patient_id,
),
*/
'order' => array(
$this->name . '.DT_CREATED_TIME',
),
'joins' => array(
array(
'table' => 'DICTIONARY_DATA',
'alias' => 'DD',
'type' => 'INNER',
'fields' => 'DD.DICTIONARY_DATA_CODE as DD_Code',
'conditions'=> array(
$this->name . '.PRIORITY_ID = DD.DICTIONARY_DATA_ID',
$this->name . '.HID' => $hospital_id,
$this->name . '.PID' => $patient_id,
)
)
),
);
$rs = $this->find('all', $params);
我在这里获取数据:
foreach ($rs as $record){
try {
$result[] = $record[$this->name];
array_push($result, $record['DD']);
}
}
并返回它以作为 JSON 对象打印出来。所以我想检查一下and$results[]
的数值。我怎么能做到这一点而不做?SOURCE_ID
ROUTE_ID
foreach