2017-08-23 19 views
0

私はjobs.deliveryDateを追加するまでうまくいきました。クエリにはまだエラーはありませんが、私の価値をエコーアウトすると、これらの奇妙な文字がエコーされます。私はそれがMySQLのデータ型と何か関係があるのだろうかと思います。この変数はDateというデータ型を持っていますが、Datetimeのデータ型を正しく取得できます。 Screen Shot of charactersmysql日付が奇妙な文字を返しています

$query = $connect->prepare(" 
    (SELECT 
    jobs.jobID, 
    jobs.jobName, 
    jobs.pdf, 
    jobs.deliveryDate, 
    jobstatus.status, 

    rooms.roomID, 
    rooms.roomName, 
    rooms.assemblyS, 
    rooms.assemblyF, 
    rooms.assembledF, 
    rooms.assemblyNeeded, 
    rooms.woodType, 
    rooms.finishType, 
    rooms.finishColor, 
    rooms.numberOfBoxes, 
    rooms.isRush, 
    rooms.description, 

    jobnotes.note 
    FROM jobs 
    LEFT JOIN rooms ON jobs.jobID = rooms.jobID 
    LEFT JOIN jobnotes ON jobnotes.jobID = jobs.jobID 
    LEFT JOIN jobstatus ON jobstatus.statusOrder = jobs.statusOrder 
    WHERE (rooms.assemblyNeeded = 1) AND ((rooms.isRush = 1 AND rooms.assemblyF = 0) OR (rooms.isRush = 1 AND rooms.assemblyF IS NULL)) 
    GROUP BY rooms.roomID) 

    UNION ALL 

    (SELECT 
    jobs.jobID, 
    jobs.jobName, 
    jobs.pdf, 
    jobs.deliveryDate, 
    jobstatus.status, 

    rooms.roomID, 
    rooms.roomName, 
    rooms.assemblyS, 
    rooms.assemblyF, 
    rooms.assembledF, 
    rooms.assemblyNeeded, 
    rooms.woodType, 
    rooms.finishType, 
    rooms.finishColor, 
    rooms.numberOfBoxes, 
    rooms.isRush, 
    rooms.description, 

    jobnotes.note 
    FROM jobs 
    LEFT JOIN rooms ON jobs.jobID = rooms.jobID 
    LEFT JOIN jobnotes ON jobnotes.jobID = jobs.jobID 
    LEFT JOIN jobstatus ON jobstatus.statusOrder = jobs.statusOrder 
    WHERE ((rooms.assemblyNeeded = 1 AND jobstatus.statusOrder >= 0 AND rooms.assemblyF IS NULL) 
    OR (rooms.assemblyNeeded = 1 AND jobstatus.statusOrder >= 0 AND rooms.assemblyF = 0)) 
    AND ((rooms.isRush = 0 AND rooms.assemblyF = 0) OR (rooms.isRush = 0 AND rooms.assemblyF IS NULL)) 
    GROUP BY jobs.jobName, rooms.finishColor 
    ORDER BY jobs.statusOrder = 7 DESC, deliveryDate, jobName, finishType LIMIT 50)"); 
if(!$query) { 
    echo("Query Failed Because " . mysqli_error($connect)); 
}; 

$query->execute(); 
$result = $query->get_result(); 


while($row = mysqli_fetch_assoc($result)) { 
    $deliveryDate = $row['deliveryDate']; 
    echo $deliveryDate; 
} 
+0

エンコードの問題を使用して、日付を取得することができましたか? – GrumpyCrouton

+0

[UTF-8の完全な複製]の可能な複製(https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Qirel

答えて

0

これは、この問題を解決するための最も適切な方法ではないかもしれないが、私はおそらく

EXTRACT(YEAR FROM jobs.deliveryDate) as deliveryDateYear, 
EXTRACT(MONTH FROM jobs.deliveryDate) as deliveryDateMonth, 
EXTRACT(DAY FROM jobs.deliveryDate) as deliveryDateDay,