Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 推进ORM:从另一个未连接直接外键的表中添加列_Php_Sql_Orm_Propel - Fatal编程技术网

Php 推进ORM:从另一个未连接直接外键的表中添加列

Php 推进ORM:从另一个未连接直接外键的表中添加列,php,sql,orm,propel,Php,Sql,Orm,Propel,我想将另一个表中的SQL列添加到我的Prope查询中,但我无法使用normal->withColumn语句实现这一点。第二个表不是通过外键与第一个表连接的,但对于第一个表中的每个条目,第二个表中正好有一个条目。两个表之间的连接是来自另外两个表的两个ID。 为了更好地理解,以下是我的表格: 条目: 身份证件 名称 专家证 或有id 偏爱: 身份证件 位置 专家证 或有id 专家和特遣队: 身份证件 ... 我希望条目表中的所有条目都有一个附加的列位置。每个条目都有一个确切的偏好。使用SQL时,此查

我想将另一个表中的SQL列添加到我的Prope查询中,但我无法使用normal->withColumn语句实现这一点。第二个表不是通过外键与第一个表连接的,但对于第一个表中的每个条目,第二个表中正好有一个条目。两个表之间的连接是来自另外两个表的两个ID。 为了更好地理解,以下是我的表格: 条目:

身份证件 名称 专家证 或有id 偏爱:

身份证件 位置 专家证 或有id 专家和特遣队:

身份证件 ... 我希望条目表中的所有条目都有一个附加的列位置。每个条目都有一个确切的偏好。使用SQL时,此查询没有问题:

选择*,从favorit中选择位置作为f,其中e.expert\u id=f.expert\u id和e.Pertential\u id=f.Pertential\u id作为e条目中的位置

但是我不知道如何用spreep创建查询。 我试过这个:

EntryQuery::创建 ->过滤器专业1 ->With Column将favorit中的位置选择为f,其中e.expert\u id=f.expert\u id和e.expert\u id=f.expert\u id,“\u favorit\u id”,“类型:int” ->发现; 但这给了我一个错误 致命错误:未捕获异常“PDOException”,消息为“SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在D:\Entwicklung\htdocs\zeiterfassung\vendor\spreep\Runtime\Adapter\Pdo\PdoStatement.php:57堆栈跟踪:0中的第1行使用near'select position from favovorit AS f,其中e.expert\u id=f.expert\u id和e.continge'D:\Entwicklung\htdocs\zeiterfassung\vendor\spreep\spreep\Runtime\Adapter\Pdo\PdoStatement.php57:PdoStatement->executeNULL 1D:\Entwicklung\htdocs\zeiterfassung\vendor\spreep\src\spreep\Runtime\Connection\StatementWrapper.php194:spreep\Runtime\Adapter\Pdo\PdoStatement->->executeNULL 2D:\Entwicklung\htdocs\zeiterfassung\vendor\spreep\spreep\Runtime\ActiveQuery\Criteria.php2633:spreep\Runtime\Connection\StatementWrapper->执行3 D:\Entwicklung\htdocs\zeiterfassung\vendor\spreep\spreep\src\spreep\Runtime\ActiveQuery in第2639行的D:\Entwicklung\htdocs\zeiterfassung\vendor\prople\prople\src\prople\Runtime\ActiveQuery\Criteria.php 如果条目表中存在一个外键到另一个表中,如或有_id或计算列,则我可以从另一个表中添加一列: EntryQuery::创建 ->过滤器专业1 ->加入'Entry.特遣队' ->列为“特遣队名称”,“特遣队名称” ->使用LeftTimeDiffTimeDiffTimeEnd、timeBegin、pause、5、“_duration”、“键入:时间”
->发现

我找到了解决问题的方法: $result=EntryQuery::create ->filterByExpertId$id ->加入'Entry.特遣队' ->加入“特遣队,我喜欢它” ->其中'Favorit.expert_id=?',$id ->使用列“Favorit.position”和“U position” ->发现; 有了这个,我得到了正确的答案。但我还有一个问题:

如果存在一个条目,对应的专家和特遣队,但没有favorit,则此条目将不显示我的实际查询。在这些情况下,我也希望将此条目作为额外条目,但其位置具有一些默认值,如null或0