具有多个值的字段mysql

时间:2017-03-23 10:25:43

标签: php mysql

我在回复表中有一个字段 reply_level

   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);
    }
}

我想将几个值传递给reply_level ,无论是reply_level,reply_level1,reply _level2,reply_level3 ......(取决于子注释的级别)。如何传递多个值?我使用pdo mysql。

谢谢

0 个答案:

没有答案