我无法得到
$result = DatabaseHandler::query($query);
while ($row = $result->fetch_assoc()) {
$this->mTaskDateCreated[] = $row;
}
在用户提交表单后输出时间。由于其他两个$result
返回输入到字段中的文本,因此我不确定问题的确切位置。
如何让$result
返回datetime
的值?
<?php
class ProjectBody {
public $mTasks = array();
public $mTaskName = array();
public $mTaskDateCreated = array();
public function __construct() {
if(isset($_POST['task_name']) && isset($_POST['task'])) {
$task_name = DatabaseHandler::escape($_POST['task_name']);
$task = DatabaseHandler::escape($_POST['task']);
$query = "INSERT INTO `project` (name, task, date_created) VALUES ('$task_name', '$task', NOW())";
$result = DatabaseHandler::query($query);
}
$query = "SELECT * FROM `project` ORDER BY `id` DESC";
$result = DatabaseHandler::query($query);
while ($row = $result->fetch_assoc()) {
$this->mTaskName[] = $row;
}
$result = DatabaseHandler::query($query);
while ($row = $result->fetch_assoc()){
$this->mTasks[] = $row;
}
$result = DatabaseHandler::query($query);
while ($row = $result->fetch_assoc()) {
$this->mTaskDateCreated[] = $row;
}
}
}
?>
感谢。