Doctrine时间格式,结果返回null

时间:2014-03-26 13:22:32

标签: php mysql doctrine-orm

您好所有stackoverflow成员。 我有问题,当我从存储库创建查询时:

$EntityManger->getRepository('\Entity\NotifyModulesParams')->findByModule($module);

它在时间类型字段中返回null,我在下面给出了var_dump示例:

array (size=1)
  0 => 
    object(Entity\NotifyModulesParams)[124]
      private 'id' => int 5
      private 'param' => string 'interval1' (length=9)
      private 'value' => string '12.5' (length=4)
      private 'from' => null
      private 'to' => null

这是我的Doctrine类代码列表:

<?php
namespace Entity;

use \Doctrine\ORM\Mapping as ORM;

/**
 * Params
 *
 * @ORM\Table(
 *      name="params",
 *      uniqueConstraints={
 *          @ORM\UniqueConstraint(name="param", columns={"param"})
 *      }
 * )
 * @ORM\Entity(repositoryClass="\Repository\ParamsRepository")
 */
class Params
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="param", type="string", length=100, nullable=false)
     */
    private $param;

    /**
     * @var string
     *
     * @ORM\Column(name="value", type="string", length=100, nullable=true)
     */
    private $value;

    /**
     * @var float
     *
     * @ORM\Column(name="deviation", type="float", precision=10, scale=0, nullable=true)
     */
    private $deviation;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="from", type="time", nullable=true)
     */
    private $from;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="to", type="time", nullable=true)
     */
    private $to;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set param
     *
     * @param string $param
     * @return NotifyModulesParams
     */
    public function setParam($param)
    {
        $this->param = $param;

        return $this;
    }

    /**
     * Get param
     *
     * @return string
     */
    public function getParam()
    {
        return $this->param;
    }

    /**
     * Set value
     *
     * @param string $value
     * @return NotifyModulesParams
     */
    public function setValue($value)
    {
        $this->value = $value;

        return $this;
    }

    /**
     * Get value
     *
     * @return string
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * Set deviation
     *
     * @param float $deviation
     * @return NotifyModulesParams
     */
    public function setDeviation($deviation)
    {
        $this->deviation = $deviation;

        return $this;
    }

    /**
     * Get deviation
     *
     * @return float
     */
    public function getDeviation()
    {
        return $this->deviation;
    }

    /**
     * Set from
     *
     * @param \DateTime $from
     * @return NotifyModulesParams
     */
    public function setFrom($from)
    {
        $this->from = $from;

        return $this;
    }

    /**
     * Get from
     *
     * @return \DateTime
     */
    public function getFrom()
    {
        return $this->from;
    }

    /**
     * Set to
     *
     * @param \DateTime $to
     * @return NotifyModulesParams
     */
    public function setTo($to)
    {
        $this->to = $to;

        return $this;
    }

    /**
     * Get to
     *
     * @return \DateTime
     */
    public function getTo()
    {
        return $this->to;
    }
}

存储在mySql中的数据:

INSERT INTO `notify_modules_params` (`param`, `value`, `deviation`, `from`, `to`) VALUES
('interval', '12.5', 2.5, '01:40:00', '04:04:00');

有人能用时间格式知道这个问题吗?

更新

这是mySql表转储:

CREATE TABLE IF NOT EXISTS `params` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `param` varchar(100) NOT NULL,
  `value` varchar(100) DEFAULT NULL,
  `deviation` float DEFAULT NULL,
  `from` time DEFAULT NULL,
  `to` time DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `param` (`param`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

0 个答案:

没有答案