douxia1988 2017-03-23 10:25
浏览 28

具有多个值的字段mysql

I have a field reply_level in a reply table.    

   protected function buildDomainObject(array $row)
{
    $reply = new Reply();
    $reply->setId($row['reply_id']);
    $reply->setAuthor($row['reply_author']);
    $reply->setContent($row['reply_content']);
    $reply->setComParent($row['com_id']);
    $reply->setLevel($row['reply_level']);

    if (array_key_exists('art_id', $row))
    {
        $commentaireId = $row['art_id'];
        $article = $this->articleDAO->find($commentaireId);
        $reply->setArticle($article);
    }
    return $reply;
}

public function save(Reply $reply) {

    $commentData = array(
        'reply_content' => $reply->getContent(),
        'reply_author' => $reply->getAuthor(),
        'com_id'    => $reply->getComParent(),
        'art_id'    => $reply->getArticle()->getId(),
        'reply_level'   => $reply->getLevel()
    );

    if ($reply->getId()) {
        // update comment
        $this->getDb()->update('t_reply', $commentData, array('reply_id' => $reply->getId()));
    } else {
        // The comment has never been saved : insert it
        $this->getDb()->insert('t_reply', $commentData);
        // Get the id of the newly created comment and set it on the entity.
        $id = $this->getDb()->lastInsertId();
        $reply->setId($id);
    }
}

I would like to pass several values to reply_level, either reply_level, reply_level1, reply _level2, reply_level3 ...(Depending on the level of the sub-comment). How to pass multiple values ? i use pdo mysql.

Thank you

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法