donglaogu3788 2014-11-14 21:36
浏览 43

Mysql不存储blob列数据

I have strange problem that I am unable to figure out, any help would be appreciated!.

The problem is I am trying to store an object into mysql database, when I execute the insertion command I run successfully, but when I check the table, all columns have the new inserted data expect the column with Blob datatype.

here is the table

CREATE TABLE `uc_opportunities` (
 `post_id` int(11) NOT NULL AUTO_INCREMENT,
 `org_id` int(11) DEFAULT NULL,
 `dateTime` int(11) NOT NULL,
`subject` varchar(200) NOT NULL,
`text` varchar(2000) DEFAULT NULL,
`zipcode` varchar(10) NOT NULL,
`location` varchar(100) DEFAULT NULL,
`schedule` blob NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8;

and here is the insertion function:

public function addOpportunity($org_id)
{
    global $mysqli,$emailActivation,$websiteUrl,$db_table_prefix; // 

    echo "inside add opportunity<br>";
    var_dump($this->schedule);

    $stmt = $mysqli->prepare("INSERT INTO ".$db_table_prefix."opportunities (
        org_id,
        dateTime,
        subject,
        text,
        zipcode,
        schedule
        )
        VALUES (
        ?,
        ?,
        ?,
        ?,
        ?,
        ?
        )");

    $schedule_serialized = serialize($this->schedule);      
    $stmt->bind_param("iissib", $org_id, $this->dateTime, $this->subject,$this->postText, $this->zipcode, $schedule_serialized );
    $result = $stmt->execute();

    echo "execution result ".$result."<br>";
    $inserted_id = $mysqli->insert_id;
    $stmt->close();

    $this->post_id = $inserted_id;

    }

All columns except schedule are inserted, I check if the insertion function receive the schedule correctly using var_dump($this->schedule) and it is correct. What do you think might be the problem?

Thank you

  • 写回答

2条回答 默认 最新

  • drjyvoi734793 2014-11-14 21:57
    关注

    Please check out the mysqli documentation in reference to saving blob data and mysql config for max_allowed_packet. It's possible this could be your issue since I don't know how big your serialized data is:

    php.net mysqli

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器