dousuie2222 2016-06-01 19:35
浏览 46

通过PDO调用存储过程时,不保存MySQL ENUM值

I have created this stored procedure:

CREATE PROCEDURE LogAdd(
    IN log_title VARCHAR(128),
    IN log_type ENUM('message','warning','error'),
    IN log_info TEXT
) 
DETERMINISTIC 
MODIFIES SQL DATA 
COMMENT 'Insert a new log entry' 
BEGIN
    INSERT INTO `tbl_logs` (
        `title`,
        `type`,
        `info`
    )
    VALUES (
        log_title,
        log_type,
        log_info
    );
END

which works when executed with data directly added in the query. But when I bind parameters, the type column, which is of ENUM type, is not saved (is empty). I can see that the value is sent as a string:

$stmt = $pdo -> prepare("CALL LogAdd(?, ?, ?)");
$stmt -> bindParam(1, 'Message title');
$stmt -> bindParam(2, 'message');
$stmt -> bindParam(3, 'Message information');

$stmt -> execute();

Why isn't the ENUM value saved?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料