小编Sep*_*deh的帖子

部分选择学说查询生成器

我正在尝试自定义选择使用此代码

$result = $qb->select('partial user.{id,name}')
                 ->from('User', 'user')
                 ->leftJoin('user.group', 'group')
                 ->getQuery()
                 ->getResult(); 
Run Code Online (Sandbox Code Playgroud)

下面这段代码的结果

{
    "id": 10,
    "name": "admin",
    "description": null,
    "create_date": null,
    "modified_date": null,
}
Run Code Online (Sandbox Code Playgroud)

为什么返回的字段没有选择空值?!

symfony doctrine-orm

1
推荐指数
1
解决办法
9880
查看次数

将字符串映射到函数

我正在尝试执行此操作,但它不起作用,这是我的错误:

必须使用'。'或'-> '调用'((test *)this)-> test :: mapping.std :: map <_Key,_Tp,_Compare,_Alloc> :: operator []中的指针成员函数(test :: *)(int),std :: less>,std :: allocator,void(test :: *)(int)>>>((((const key_type)(&str))))(... )”,例如“(...-> *((test *)this)-> test :: mapping.std :: map <_Key,_Tp,_Compare,_Alloc> :: operator [],void(test :: *)(int),std :: less>,std :: allocator,void(test :: *)(int)>>>((((const key_type)(&str))))(...)'

test.h:

#include....
using namespace std;
class test
{
    public:
       std::map<std::string, void(test::*)(int)> mapping;
    void Add(int);
};

test.cpp:

test::test()
{
   mapping["Add"]=&test::Add;
   string str = "Add";
   this.*mapping[str](3);// dosnt work!!!!
}

void …
Run Code Online (Sandbox Code Playgroud)

c++ map

-1
推荐指数
1
解决办法
691
查看次数

标签 统计

c++ ×1

doctrine-orm ×1

map ×1

symfony ×1