我有一些加载工作时间的代码。我的数据库看起来像
id - int(11)
day - varchar(255)
starttime - (time)
endtime - (time)
date - (date)
type - int(1)
我尝试通过以下方式获取数据:
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
function get_all_records($sql){
global $conn;
$result = $conn->query($sql);
$result = [];
while($row = $result->fetch_assoc()) $result[array_shift($row)] = $row;
return $result;
}
$sql = "SELECT day, starttime, endtime FROM schedule WHERE type = ";
$shop_hours = array_merge(
get_all_records($sql . "0 ORDER BY id"),
get_all_records($sql . "1 and YEARWEEK('DATE') = '201915'")
);
var_dump ($shop_hours);
?>
仅显示内容已成功连接
三国纷争
料青山看我应如是