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 に答える