1
我有一个从MySQL获取数据的类的函数。所有的作品都可以,但我也想知道如何获取MySQL数据的列名。PHP PDO获取MySQL文件名
这里是我的代码:
public static function getTickets(){
$conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
$sql = "select tickets.*,customers.* from tickets,customers where
(tickets.ticket_customer_id = customers.customer_id) order by tickets.ticket_open_date desc ";
$st = $conn->prepare($sql);
$st->execute();
$list = array();
while($row=$st->fetch()) {
$tickets = New Tickets($row);
$list[] = $tickets;
}
//total rows of customer
$sql = "select FOUND_ROWS() as totalRows";
$totalRows = $conn->query($sql)->fetch();
$conn=null;
$columnCount = $st->columnCount();
//pass the values to page
return (array("results"=>$list ,"totalRows"=>$totalRows,"columnCount"=>$columnCount));
}