so i'm trying to get this query to work :
SELECT
projects.title ,
projects.deadline,
projects.status ,
CASE WHEN projects.client_type = 1 THEN (SELECT clients.firstname from clients where clients._= projects.client )
WHEN projects.client_type = 2 THEN (SELECT concat(companies.firstname,' ( ',companies.fantasy,' )') from companies where companies._= projects.client )
END AS 'client'
FROM projects
Result
title deadline status client
------------------------------------------------------
SEO 2016-05-07 1 Jhon 123 ( COMPANY NAME )
TEST 2016-05-07 1 Jhon 123 ( COMPANY NAME )
The thing is the phql does not work , heres the code and the results :
public function IndexAction()
{
$qq = "
SELECT
Manager\Models\Projects.title ,
Manager\Models\Projects.deadline,
Manager\Models\Projects.status ,
CASE WHEN Manager\Models\Projects.client_type = 1
THEN (SELECT Manager\Models\Clients.firstname from Manager\Models\Clients where Manager\Models\Clients._= Manager\Models\Projects.client )
WHEN Manager\Models\Projects.client_type = 2
THEN (SELECT concat(Manager\Models\Companies.firstname,' ( ',Manager\Models\Companies.fantasy,' )') from Manager\Models\Companies where Manager\Models\Companies._= Manager\Models\Prohects.client )
END AS 'client'
FROM Manager\Models\Projects";
$r = $this->modelsManager->executeQuery($qq);
$this->view->disable();
var_dump($r);
}
Result
Syntax error, unexpected token IDENTIFIER(Manager\Models\Projects), near to '.client_type = 1 THEN (SELECT Manager\Models\Clients.firstname from Manager\Models\Clients where Manager\Models\Clients._= Manager\Models\Projects.client ) WHEN Manager\Models\Projects.client_type = 2 THEN (SELECT concat(Manager\Models\Companies.firstname,' ( ',Manager\Models\Companies.fantasy,' )') from Manager\Models\Companies where Manager\Models\Companies._= Manager\Models\Prohects.client ) END AS 'client' FROM Manager\Models\Projects', when parsing: SELECT Manager\Models\Projects.title , Manager\Models\Projects.deadline, Manager\Models\Projects.status , CASE WHEN Manager\Models\Projects.client_type = 1 THEN (SELECT Manager\Models\Clients.firstname from Manager\Models\Clients where Manager\Models\Clients._= Manager\Models\Projects.client ) WHEN Manager\Models\Projects.client_type = 2 THEN (SELECT concat(Manager\Models\Companies.firstname,' ( ',Manager\Models\Companies.fantasy,' )') from Manager\Models\Companies where Manager\Models\Companies._= Manager\Models\Prohects.client ) END AS 'client' FROM Manager\Models\Projects (663)