gpt4 book ai didi

php - php 页面中的查询不起作用

转载 作者:行者123 更新时间:2023-11-30 00:35:48 24 4
gpt4 key购买 nike

<?php

$selectdelegatedtasks = "select delegation_cycle.delegation_cycle_id as task_id,delegation_cycle.delegate_from_id as from_id,delegation_cycle.delegate_to_id as to_id,delegation_cycle.time_estimate as main_time_estimate,delegation_cycle.status as main_task_status ,delegation_cycle.start_date as main_start_date,delegation_cycle.changes,DATE(delegation_cycle.delegated_time) as orginal_email_time,tasks.task_name,tasks.client_id,tasks.followup,tasks.task_owner,tasks.main_due_date,tasks.main_priority,1 as delegated,delegation_user_relation.showinlist,users.email as email_from,clients.client_name, @delegationcount:=(select count(delegation_cycle_id) from delegation_cycle where delegation_cycle.task_id=tasks.task_id and delegation_cycle.task_parent='$loggeduserid') as delegationcount, @sumstatus:=(select sum(status) from delegation_cycle where delegation_cycle.task_id=tasks.task_id and delegation_cycle.task_parent='$loggeduserid' and delegation_cycle.status='4') as sumstatus, (select count(notes_records_id) from notes_records join notes ON notes.notes_id = notes_records.notes_id where notes_to = '$loggeduserid' and notes.task_id = delegation_cycle.task_id ) as notescount,(select count(notes_records_id) from notes_records join notes ON notes.notes_id = notes_records.notes_id where notes_to = '$loggeduserid' and notes.task_id = delegation_cycle.task_id and notes_records.read=0) as unreadnotescount from delegation_cycle inner join tasks on tasks.task_id=delegation_cycle.task_id inner join users on users.user_id=delegation_cycle.delegate_from_id inner join clients on clients.client_id=tasks.client_id join delegation_user_relation on delegation_user_relation.delegate_task_id=tasks.task_id where (case when delegation_cycle.status=3 || @delegationcount*4=@sumstatus then delegation_user_relation.user_id='$loggeduserid' and delegation_cycle.delegate_to_id='$loggeduserid' and delegation_cycle.status!=4 else (delegation_user_relation.showinlist=1 || delegation_user_relation.showinlist=2) and delegation_user_relation.user_id='$loggeduserid' and delegation_cycle.delegate_to_id='$loggeduserid' and delegation_cycle.status!=4 end )";


$resultqw1 = $this -> objDBConn -> exceuteQuery($selectdelegatedtasks);
print_r($resultqw1);

?>

$loggeduserid 被 4 替换,查询如下所示;

 select 
delegation_cycle.delegation_cycle_id as task_id,
delegation_cycle.delegate_from_id as from_id,
delegation_cycle.delegate_to_id as to_id,
delegation_cycle.time_estimate as main_time_estimate,
delegation_cycle.status as main_task_status,
delegation_cycle.start_date as main_start_date,
delegation_cycle.changes,
DATE(delegation_cycle.delegated_time) as orginal_email_time,
tasks.task_name,
tasks.client_id,
tasks.followup,
tasks.task_owner,
tasks.main_due_date,
tasks.main_priority,
1 as delegated,
delegation_user_relation.showinlist,
users.email as email_from,
clients.client_name,
@delegationcount:=(select
count(delegation_cycle_id)
from
delegation_cycle
where
delegation_cycle.task_id = tasks.task_id
and delegation_cycle.task_parent = '4') as delegationcount,
@sumstatus:=(select
sum(status)
from
delegation_cycle
where
delegation_cycle.task_id = tasks.task_id
and delegation_cycle.task_parent = '4'
and delegation_cycle.status = '4') as sumstatus,
(select
count(notes_records_id)
from
notes_records
join
notes ON notes.notes_id = notes_records.notes_id
where
notes_to = '4'
and notes.task_id = delegation_cycle.task_id) as notescount,
(select
count(notes_records_id)
from
notes_records
join
notes ON notes.notes_id = notes_records.notes_id
where
notes_to = '4'
and notes.task_id = delegation_cycle.task_id
and notes_records.read = 0) as unreadnotescount
from
delegation_cycle
inner join
tasks ON tasks.task_id = delegation_cycle.task_id
inner join
users ON users.user_id = delegation_cycle.delegate_from_id
inner join
clients ON clients.client_id = tasks.client_id
join
delegation_user_relation ON delegation_user_relation.delegate_task_id = tasks.task_id
where
(case
when
delegation_cycle.status = 3
|| @delegationcount * 4 = @sumstatus
then
delegation_user_relation.user_id = '4'
and delegation_cycle.delegate_to_id = '4'
and delegation_cycle.status != 4
else (delegation_user_relation.showinlist = 1
|| delegation_user_relation.showinlist = 2)
and delegation_user_relation.user_id = '4'
and delegation_cycle.delegate_to_id = '4'
and delegation_cycle.status != 4
end)

我正在使用这个查询,它在 mysql 工作台中运行良好,当我尝试从 php 页面执行此查询时,在 phpmyadmin 中它不起作用,请帮助我解决这个问题

最佳答案

    <?php $sql=" SET @delegationcount:=0;";
$this->objDBConn->exceuteQuery($sql);
$sql1=" SET @sumstatus:=0;";
$this->objDBConn->exceuteQuery($sql1);
$selectdelegatedtasks = "select delegation_cycle.delegation_cycle_id as task_id,delegation_cycle.delegate_from_id as from_id,delegation_cycle.delegate_to_id as to_id,delegation_cycle.time_estimate as main_time_estimate,delegation_cycle.status as main_task_status ,delegation_cycle.start_date as main_start_date,delegation_cycle.changes,DATE(delegation_cycle.delegated_time) as orginal_email_time,tasks.task_name,tasks.client_id,tasks.followup,tasks.task_owner,tasks.main_due_date,tasks.main_priority,1 as delegated,delegation_user_relation.showinlist,users.email as email_from,clients.client_name, @delegationcount:=(select count(delegation_cycle_id) from delegation_cycle where delegation_cycle.task_id=tasks.task_id and delegation_cycle.task_parent='$loggeduserid') as delegationcount, @sumstatus:=(select sum(status) from delegation_cycle where delegation_cycle.task_id=tasks.task_id and delegation_cycle.task_parent='$loggeduserid' and delegation_cycle.status='4') as sumstatus, (select count(notes_records_id) from notes_records join notes ON notes.notes_id = notes_records.notes_id where notes_to = '$loggeduserid' and notes.task_id = delegation_cycle.task_id ) as notescount,(select count(notes_records_id) from notes_records join notes ON notes.notes_id = notes_records.notes_id where notes_to = '$loggeduserid' and notes.task_id = delegation_cycle.task_id and notes_records.read=0) as unreadnotescount from delegation_cycle inner join tasks on tasks.task_id=delegation_cycle.task_id inner join users on users.user_id=delegation_cycle.delegate_from_id inner join clients on clients.client_id=tasks.client_id join delegation_user_relation on delegation_user_relation.delegate_task_id=tasks.task_id where (case when delegation_cycle.status=3 || @delegationcount*4=@sumstatus then delegation_user_relation.user_id='$loggeduserid' and delegation_cycle.delegate_to_id='$loggeduserid' and delegation_cycle.status!=4 else (delegation_user_relation.showinlist=1 || delegation_user_relation.showinlist=2) and delegation_user_relation.user_id='$loggeduserid' and delegation_cycle.delegate_to_id='$loggeduserid' and delegation_cycle.status!=4 end )";


$resultqw1 = $this -> objDBConn -> exceuteQuery($selectdelegatedtasks);
print_r($resultqw1);
?>

在使用当前 session 之前需要设置临时 session 变量。

关于php - php 页面中的查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22190685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com