使用propel从OneToOne关系中获取JSON

时间:2016-03-21 22:28:30

标签: php json left-join propel one-to-one

我将从我的数据库中获取跟随结构的JSON:

{
"Users": [
    {
        "Id": 1,
        "Name": "a",
        "Family": "b",
        "RegisterId": 1,
        "AccessType": 1,
        "Username": "abc"
    },
    {
        "Id": 2,
        "Name": "x",
        "Family": "y",
        "RegisterId": 2,
        "AccessType": 1,
        "Username": "xyz"
    }
]
}

Id,Name,Family,RegisterId,AccessType是User_TBL列,Username是Register_TBL列。

我可以使用以下查询获取此JSON:

SELECT u.id,u.name,u.family,u.access_type,u.register_id,r.username
FROM `user` as u LEFT JOIN `register` as r 
ON u.register_id = r.id

我正在尝试使用propel,但它只显示所有User_TBL列。

$userList = UserQuery::create()-> joinWith('User.Register')-> find();

你的建议是什么?!

1 个答案:

答案 0 :(得分:0)

我使用下面的代码,它解决了我的问题。

@Override
    // New services discovered
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            for (BluetoothGattService gattService : gatt.getServices()) {
                for (BluetoothGattCharacteristic mCharacteristic : gattService.getCharacteristics()) {
                    Log.i(TAG, "Found Characteristic: " + mCharacteristic.getUuid().toString());
                }
                Log.i(TAG, "onServicesDiscovered UUID: " + gattService.getUuid().toString());
            }
        } else {
            Log.w(TAG, "onServicesDiscovered received: " + status);
        }