Ich schreibe diese Abfrage in yii2 -Yii2 Abfrage: Zugriff Array-Elemente in Objekt von einer Abfrage zurück
$senderInfo[] = Customers::find()->where(['cust_id' => $resShipment['ship_shipper_id'], 'cust_country_code' => Yii::$app->user->identity->country_code])->distinct()->all();
und bekommen dies als Folge -
Array ([0] => Array ()) Array ([0] => Array () [1] => Array ()) Array ([0] => Array () [1] => Array () [2] => Array ([0] => common\models\Customers Object ([_attributes:yii\db\BaseActiveRecord:private] => Array ([cust_id] => 79 [cust_user_id] => 2 [cust_designation] => Mr [cust_fname] => abcd [cust_mname] => xyz [cust_lname] => xyz [cust_country_code] => 91 [cust_mobile] => 8888888888 [cust_email] => [email protected] [cust_id_proof] => [cust_country] => [cust_state] => [cust_city] => [cust_location] => [cust_street] => [cust_address] => delhi [cust_pobox] => 02881 [cust_additional_detail] => [cust_picture] => [verified] => Yes [created] => 2016-04-20 14:45:42 [updated] => 0000-00-00 00:00:00 [deleted] => No) [_oldAttributes:yii\db\BaseActiveRecord:private] => Array ([cust_id] => 79 [cust_user_id] => 2 [cust_designation] => Mr [cust_fname] => abcd [cust_mname] => xyz [cust_lname] => xyz [cust_country_code] => 91 [cust_mobile] => 8888888888 [cust_email] => [email protected] [cust_id_proof] => [cust_country] => [cust_state] => [cust_city] => [cust_location] => [cust_street] => [cust_address] => delhi [cust_pobox] => 413714 [cust_additional_detail] => [cust_picture] => [verified] => Yes [created] => 2016-04-20 14:45:42 [updated] => 0000-00-00 00:00:00 [deleted] => No) [_related:yii\db\BaseActiveRecord:private] => Array () [_errors:yii\base\Model:private] => [_validators:yii\base\Model:private] => [_scenario:yii\base\Model:private] => default [_events:yii\base\Component:private] => Array () [_behaviors:yii\base\Component:private] => Array ())))
Aber wegen der leeren Arrays am Anfang von Dieses Array kann ich nicht auf die Elemente zugreifen. Ich muss es in einer (strikt) Schleife bevölkern, nachdem es zugänglich wird.
Versuchen Sie dies mit der Verwendung von 'asArray()', '$ senderInfo [] = Kunden :: find() -> wo (['cust_id' => $ resShipment ['ship_shipper_id'], 'cust_country_code' => Yii :: $ app-> benutzer-> identity-> country_code]) -> distinct() -> asArray() - > all(); ' –
es hat auch nicht funktioniert. –