You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
895 B
39 lines
895 B
<?php
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
require_once('../conn.php');
|
|
header("Content-Type: application/json");
|
|
$d = new Department();
|
|
echo $d->getDepartment();
|
|
}
|
|
|
|
class Department
|
|
{
|
|
public function getDepartment()
|
|
{
|
|
global $conn;
|
|
|
|
$sql_str = "
|
|
SELECT
|
|
* FROM(
|
|
SELECT
|
|
'0' AS value,
|
|
'全部' AS text
|
|
FROM department
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
DISTINCT
|
|
department_id AS value,
|
|
name AS text
|
|
FROM department
|
|
)AS tmp
|
|
ORDER BY tmp.value
|
|
";
|
|
$stmt = $conn->prepare($sql_str);
|
|
$stmt->execute();
|
|
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|
|
|