I have a query in my php script that is handled by PDO. To be exact it's 2 queries in 1 statement. The query itself runs fine in SQL client (I'm using HeidiSQL). PHP however gives me exactly this error: "SQLSTATE[HY000]: General error" with nothing else. No error number or message.
Is there a way to debug the query somehow? I don't think there's an error in query itself, so I don't know what's wrong. Nothing shows in mysql error log. I've enabled mysql general log, but it only logs query itself without showing an error.
My stack: XAMPP 1.8, Apache 2.4.3, PHP 5.4.7, MySQL 5.5.27
This is my query (it's rather long):
    /*First query - generating temp table with overdue jobs*/
    CREATE TEMPORARY TABLE temp AS (
        SELECT  j.NetworkID,
            @clientID := j.ClientID,
            j.BranchID,
            j.ServiceProviderID,
            (   
                (DATEDIFF(CURDATE(), j.DateBooked)) 
                - 
                IF(
                (@unit :=   (
                    SELECT      uctype.UnitTurnaroundTime
                    FROM        job
                    LEFT JOIN   product ON job.ProductID = product.ProductID
                    LEFT JOIN   unit_type AS utype ON product.UnitTypeID = utype.UnitTypeID
                    LEFT JOIN   unit_client_type AS uctype 
                            ON utype.UnitTypeID = uctype.UnitTypeID 
                            AND uctype.ClientID = @clientID
                    WHERE       job.JobID = j.JobID
                    )
                ) IS NOT NULL,      /*statement*/
                @unit,          /*TRUE - Client Unit Type has turnaround time assigned in the db*/  
                IF(         /*FALSE - Now checking if Client Default Turnaround Time is set*/
                    (@clnt := (
                        SELECT  DefaultTurnaroundTime AS dtt
                        FROM    client
                        WHERE   client.ClientID = @clientID
                    )
                    ) IS NOT NULL,  /*statement*/
                    @clnt,      /*TRUE - Client Default Turaround time is set*/
                    (           /*FALSE - falling back to general default*/
                    SELECT  gen.Default
                    FROM    general_default AS gen
                    WHERE   gen.GeneralDefaultID = 1
                    )
                )
                )
            ) AS overdue
        FROM    job AS j
        HAVING  overdue > 0
    );
    /*Second query - filtering out overdue jobs with specific time range*/
    SELECT  COUNT(*) AS number
    FROM    temp
    WHERE   overdue >= :from AND overdue <= :to AND overdue != 0
UPDATE: The problem seems to be caused by PDO refusing to run several queries in one statement. I've inserted this before executing query:
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
So now "General error" is gone, but I'm getting
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax
just after the first query, meaning that PDO just runs one query and refuses to continue...
 
    