使用Doctrine获取值数组

时间:2017-04-17 19:09:19

标签: php arrays symfony doctrine-orm doctrine

我正在使用Symfony2和Doctrine从数据库中获取值数组。我想要一个数据库表的一个字段的值列表。

我正在使用以下代码:

        return $this->createQueryBuilder('ad')
        ->select('ad.extId')
        ->where('ad.extId is not NULL')
        ->getQuery()
        ->getArrayResult();

返回以下数组:

Array
(
    [0] => Array
        (
            [extId] => 3038
        )
)

我想撤销以下内容:

Array
(
    [0] => 3038
)

如果没有额外的foreach循环,任何人都可以直接从Doctrine获取此信息吗?

1 个答案:

答案 0 :(得分:2)

如果没有定制保湿剂,我认为不可能开箱即用。但是,您可以执行此操作(类似于<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:id="@+id/scrollView" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_alignParentTop="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <EditText android:layout_width="match_parent" android:layout_height="70dp" android:hint="edit text" /> <EditText android:layout_width="match_parent" android:layout_height="70dp" android:hint="edit text" /> </LinearLayout> </ScrollView> <Button android:layout_width="match_parent" android:layout_height="40dp" android:layout_alignParentBottom="true" android:text="button" /> </RelativeLayout> ):

foreach
相关问题