0

嘿,我有一个使用IN关键字的查询。如何将其转换为 zend 选择查询?

这是原始 SQL 形式的查询:

SELECT
            rs_credit_score,
            rs_fraud_score
FROM
            provenir_instance_response
WHERE
            application_number = @in_applcation_number
AND channel = @in_channel
AND final_decision_reason IN (
            'Failed CallCredit Delphi ID Check',
            'Failed Delphi KORules',
            'Credit Score Cut Matrix Failure',
            'Fraud Score Cut Matrix Failure',
            'Teletrack Rule Failure'

到目前为止,这是我在 Zend 中所拥有的:

public function scoreQuery($memId, $channel){
    //Build Query
    $select = $this->select();
    $select->from('provenir_instance_response', array('rs_credit_score', 'rs_fraud_score'));
    $select->where('application_number=?', $memId);
    $select->where('channel=?', $channel);
    $select->where('final_decision_reason IN Failed CallCredit Delphi ID Check');
    $select->where('final_decision_reason IN Failed Delphi KORules');
    $select->where('final_decision_reason IN Credit Score Cut Matrix Failure');
    $select->where('final_decision_reason IN Fraud Score Cut Matrix Failure');
    $select->where('final_decision_reason IN Teletrack Rule Failure');
    $result = $this->fetchAll($select);
    return $result;
}

或者也许这个?

public function scoreQuery($memId, $channel){
    //Build Query
    $select = $this->select();
    $select->from('provenir_instance_response', array('rs_credit_score', 'rs_fraud_score'));
    $select->where('application_number=?', $memId);
    $select->where('channel=?', $channel);
    $select->where('final_decision_reason IN (
    \'Failed CallCredit Delphi ID Check\',
        \'Failed Delphi KORules\',
        \'Credit Score Cut Matrix Failure\',
        \'Fraud Score Cut Matrix Failure\',
        \'Teletrack Rule Failure\'

    )');
    $result = $this->fetchAll($select);
    return $result;
}

我觉得应该是这样的?

public function scoreQuery($memId, $channel){
    //Build Query
    $select = $this->select();
    $select->from('provenir_instance_response', array('rs_credit_score', 'rs_fraud_score'));
    $select->where('application_number=?', $memId);
    $select->where('channel=?', $channel);
    $select->where('final_decision_reason IN (?)', array(
        'Failed CallCredit Delphi ID Check',
        'Failed Delphi KORules',
        'Credit Score Cut Matrix Failure',
        'Fraud Score Cut Matrix Failure',
        'Teletrack Rule Failure'
    ));
    $result = $this->fetchAll($select);
    return $result;
}

我是否正确地理解了这一点,或者如何重构我的代码?

谢谢

内森:)

4

1 回答 1

0
public function scoreQuery($memId, $channel){
//Build Query
$select = $this->select();
$select->from('provenir_instance_response', array('rs_credit_score', 'rs_fraud_score'));
$select->where('application_number=?', $memId);
$select->where('channel=?', $channel);
$select->where('final_decision_reason IN (?)', array(
    'Failed CallCredit Delphi ID Check',
    'Failed Delphi KORules',
    'Credit Score Cut Matrix Failure',
    'Fraud Score Cut Matrix Failure',
    'Teletrack Rule Failure'
));
$result = $this->fetchAll($select);
return $result;

}

于 2013-10-02T13:31:14.973 回答