简体   繁体   中英

Zend_Db_Table_Abstract and MySQL IN Keyword

Hey I have a query that uses the IN keyword. How can I translate this to the zend select query?

This is the query in raw SQL form:

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'

and here is what I have in Zend thus far:

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;
}

Or maybe this?

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;
}

I think it should be like this?

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;
}

Have I got this about right or how would refactor my code?

Thanks

Nathan :)

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;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM