0

我有以下数据结构。我可以使用where具有正常字段的条件,但不能使用数组中的条件。

数据结构

Array
(
    [AdjustmentAmount] => Array
        (
            [_] => 0
            [currencyID] => AUD
        )

    [AmountPaid] => Array
        (
            [_] => 0
            [currencyID] => AUD
        )

    [AmountSaved] => Array
        (
            [_] => 0
            [currencyID] => AUD
        )

    [BuyerUserID] => mzkfx400

 [ShippingDetails] => Array
        (
            [SalesTax] => Array
                (
                    [SalesTaxPercent] => 0
                    [SalesTaxState] => 
                    [ShippingIncludedInTax] => 
                    [SalesTaxAmount] => Array
                        (
                            [_] => 0
                            [currencyID] => AUD
                        )

                )

            [ShippingServiceOptions] => Array
                (
                    [ShippingService] => AU_Freight
                    [ShippingServicePriority] => 1
                    [ExpeditedService] => 
                )

            [SellingManagerSalesRecordNumber] => 60340
            [GetItFast] => 
        )

)

这个有效

 $ebayOrder = LMongo::collection('ebay_orders')->where('BuyerUserID','mzkfx400')->first();

这不起作用

 $ebayOrder = LMongo::collection('ebay_orders')->where('ShippingService','AU_Freight')->first();

所以基本上我想对数组内的字段使用 where 条件。

谢谢阿比

4

1 回答 1

0
$ebayOrder = LMongo::collection('ebay_orders')->where('ShippingService','AU_Freight')->first();

这将不起作用,因为 ShippingService 不是文档,而是它的内部元素。您必须获取 ShippingDetails,然后使用 foreach 迭代到 ShippingService。所以查询应该是这样的。

$ebayOrder = LMongo::collection('ebay_orders')->where('BuyerUserID','mzkfx400')->first();

 foreach($ebayOrder as $order)
 {
    //Code to loop over to ShippingService.
 }
于 2013-12-16T21:48:39.010 回答