PDO does not return count

1

I need to store the result count, but apparently with the PDO I can not store the value. I have already circled the select out and come the result, why can not I store the result $flag in the variable?

    $query = "SELECT COUNT(*) as flag FROM RESERVAS
              WHERE DATA_RETORNO_REAL = '0000-00-00' AND
                    COD_VEICULO = :veiculo and
                    DATE_FORMAT(DATA_SAIDA, \'%d-%m-%Y\') = :data_reserva
                    ";
    $data = $conexao->prepare($query);    // Prepare query for execution
    $data->execute(array(
    ':veiculo' => $veiculo,
    ':data_reserva' => $data_reserva
    ));
    $saidas = $data->fetch();

    $flag = $saidas['flag'];

On the outside:

    
asked by anonymous 14.12.2015 / 16:30

1 answer

2

Remove the slashes from DATE_FORMAT(DATA_SAIDA, \'%d-%m-%Y\') , slashes followed by quotation marks (single or double) escape them or the quotation marks were interpreted as part of the string and not as the delimiter.

    
14.12.2015 / 16:56