开发者

MySQL IFNULL + PHP Prepared Statements

I have a prepared statement:

$query = "Select id, start_date, IFNULL(end_date,start_date) as end_date FROM table WHERE id=?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
    $stmt->bind_result($var1, $var2, $var3);
    while ($stmt->fe开发者_Python百科tch()) {
        printf("My record: %s %s %s", $var1, $var2, $var3);
    }
}

Fields Type: id=int (11), end_date= (date), start_date= (date) I have this record in the table:

id,start_date,end_date
1,2011-09-17,NULL

When I execute this in my local server (PHP Version 5.3.3-7+squeeze3) it returns:

My record: 1 2011-09-17 2011-09-17

When I move this to my host server (PHP Version 5.2.5) it returns the fields with empty strings and zero.

My record: 0

But if I remove the IFNULL returns:

My record: 1 2011-09-17

What could be causing this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜