나는 Yii를 처음 접하고 몇 가지 생각을하고 고민 중입니다.Yii2 ActiveRecord
나는이 기능 모델을 가지고 :이 방법과 같이 호출
public static function findNonGeo()
{
$query = new CallerIdentityQuery(get_called_class());
$query->select([
'cidref', 'caller_id', 'expiry', 'conf_call',
'type', 'redirect', 'destination', 'status', 'start_date',
'statusDesc' => new \yii\db\Expression("CASE status
WHEN 0 THEN 'Deactivated'
WHEN 1 THEN 'Active'
WHEN 2 THEN 'Inactive'
WHEN 3 THEN 'Unregistered'
ELSE 'Permanently Deleted' END")])
->where(['status' => '1'])
->andWhere(['type' => 'N'])
->andWhere(['custref' => Yii::$app->user->identity->typedIdentity->getId()]);
return $query;
}
그리고 내 컨트롤러 :
$model = CallerIdentity::findNonGeo()->where(['cidref' => $id])->one();
하지만 데이터는 단지
을 무시처럼의를 반환 될 때->andWhere(['type' => 'N'])
'N'유형이 아닌 레코드를 볼 수 있기 때문에. 은 그래서 어쩌면 내가 그것을 이해뿐만 아니라 뭔가 잘못하고 나하고있어, 내 컨트롤러에서 수행하는 데하지만 난 그것을 얻을하지 않습니다
$model = CallerIdentity::findNonGeo()->where(['cidref' => $id])->andWhere(['type'=>'N'])->one();
다른 일을 findOne ($ ID)를 사용하는 경우 :
를$model = CallerIdentity::findOne($id);
null이 반환됩니다.
어떤 형태의 설명/정보를 주시면 감사하겠습니다.