0

我正在用 php 编写代码,基本上将数据从 mySQL 数据库“映射”到另一个数据库。我使用的代码如下:

$results = $this->query("select PT_FS_DATA_ID from PATIENT_FLOWSHEET_DATA where 
    DT_LAST_UPDATED_TIME = (select top 1 DT_LAST_UPDATED_TIME from PATIENT_FLOWSHEET_DATA 
    order by DT_LAST_UPDATED TIME desc) group by PT_FS_DATA_ID;");

但是,我收到一个错误:

syntax error, unexpected T_VARIABLE, expecting T_FUNCTION

在我看来,这似乎是正确的语法。我在这里缺少什么吗?我也尝试将控制器放在那里$this->controllerName->query,但这也不起作用。

完整代码:

class CaExtraFlowsheetFields extends CaBase {
public $name = 'CaExtraFlowsheetFields';

/*
NOTE: This is to take all the fields in flowsheet and
maps their id's.
*/
//public $useTable = 'ANSWER_ENTRY';
public $useTable = 'PATIENT_FLOWSHEET_DATA';
public $primaryKey = 'PT_FS_DATA_ID';

protected function getPrimaryKeyValue(
    $hospital_id,
    $patient_id,
    $admission_id = null
) {

return $patient_id;
}

//*CHANGE BEGIN*
$results = $this->query("select PT_FS_DATA_ID from PATIENT_FLOWSHEET_DATA where 
DT_LAST_UPDATED_TIME = (select top 1 DT_LAST_UPDATED_TIME from PATIENT_FLOWSHEET_DATA 
order by DT_LAST_UPDATED TIME desc) group by PT_FS_DATA_ID;");

protected $filedMethodMappings = array(

    'Method_GO' => array(
        CaBase::KEY_MAPPING_LOGIC_COMPLEXITY => CaBase::LEVEL2_COMPLEXITY,
        CaBase::KEY_FIELD_LOGIC_NAME         => 'wsMethod_GO',
);

//########################################################################//
//Note[]>Block[]               //
//>Method that calls LookUpField for every field in flowsheet //                                       //
//########################################################################//
public function wsMethod_GO ($params) {
    foreach($results as $value){

        $questionName = ''.$value;
        $msg_prefix = $this->name . "::" . __FUNCTION__ . ": ". "arrivez-vouz" ;
        $ret = $this->wsLookUpField($params,$questionName,$msg_prefix);
        return $ret;   
    } 
    unset($value);
}
//########################################################################//

public function wsLookUpField($params,$questionName,$msg_prefix){

$arrayValues=array();
    try{    
        $hospital_id  = $params[Constants::KEY_HOSPITAL_ID];
        $patient_id   = $params[Constants::KEY_PATIENT_ID];
        $admission_id = $params[Constants::KEY_ADMISSION_ID];

        $msg_prefix = $this->name . "::" . __FUNCTION__ . ": ". "attendez-vouz: l'hopital= ".$hospital_id.
        " patient= ".$patient_id." admission= ".$admission_id;

        //shows info about given question name
        $msg_prefix = "*!*!*!*Show me ---> ".$questionName." : ".$answer_entry_id.
        " = aic: " .$answer_id_check;

        $ret = array();

        //now with needed fields, grab the A_NAME:
            $params = array(
            'conditions' => array(
                $this->name . '.PID'                => $patient_id,
                $this->name . '.PT_FS_DATA_ID'      => $questionName,           
            ),
            'order' => array(
                $this->name . '.' . $this->primaryKey . ' DESC'
            ),
            'fields' => array(
                $this->name . '.FS_VALUE_TEXT',
            )
        );

    $rs = $this->find('first', $params);

   /* check to make sure $rs has received an answer from the query
      and check to make sure this answer is a part of the most recent
      database entries for this note */
    if (false != $rs) {
            try {                   
                $msg = $msg_prefix . "Data obtained successfully."."<br>".$result;
            $result = $rs;
            $ret = WsResponse::getResponse_Success($msg, $result);
        } catch (Exception $e) {
            $msg = $msg_prefix . "Exception occurred.";
            $ret = WsResponse::getResponse_Error($msg);
        }
    /*answer was not part of most recent database entries, meaning no
      answer was given for this particular question the last time this
      particular note was filled out. Message is given accordingly.*/
    } else {
        $msg = $msg_prefix . "/No answer given.";
            $ret = WsResponse::getResponse_Error($msg);
        }


    } catch (Exception $e) {
                $msg = $msg_prefix . "Exception occurred.";
                $ret = WsResponse::getResponse_Error($msg);
        }        
return $ret;
}
4

1 回答 1

2

这是你正在做的事情:

class ABC {

    $result = 'whatever';

}

你不能在那里声明一个变量!


代码需要在方法/函数中......

class ABC
{
    public function wsMethod_GO ($params)
    {
        $result = 'whatever';
    }
}
于 2012-06-18T15:08:42.443 回答