如果我调用函数getDate_created();,我的查询将不会显示时间戳。我怎样才能解决这个问题?函数getAll()可以工作。
<?php
class Post
{
public $date_created;
public function getDate_created()
{
return $this->date_created;
}
public function setDate_created($date_created)
{
$this->date_created = $date_created;
return $this;
}
public static function getAll()
{
$conn = Db::getInstance();
$result = $conn->query('SELECT * FROM images');
return $result->fetchAll(PDO::FETCH_CLASS, __CLASS__);
}
}
$posts = Post::getAll();
$timepost = new Post();
$t = $timepost->getDate_created();
var_dump($t);
表格图片:
CREATE TABLE `images` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`img_description` varchar(255) NOT NULL,
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`file_path` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Var_dump($ t)结果显示为NULL。
当年话下
一只斗牛犬