【问题标题】:Tabulator data from Postgres DatabasePostgres 数据库中的制表数据
【发布时间】:2018-10-05 14:00:43
【问题描述】:

我尝试使用此代码从文件 json.php 加载数据,它工作正常

$data = [
    [id=>1, name=>"Billy Bob", progress=>"12", gender=>"male", height=>1, col=>"red", dob=>"", driver=>1],
    [id=>2, name=>"Mary May", progress=>"1", gender=>"female", height=>2, col=>"blue", dob=>"14/05/1982", driver=>true],
    [id=>3, name=>"Christine Lobowski", progress=>"42", height=>0, col=>"green", dob=>"22/05/1982", driver=>"true"],
    [id=>4, name=>"Brendon Philips", progress=>"125", gender=>"male", height=>1, col=>"orange", dob=>"01/08/1980"],
    [id=>5, name=>"Margret Marmajuke", progress=>"16", gender=>"female", height=>5, col=>"yellow", dob=>"31/01/1999"],
];

//返回JSON格式数据

echo(json_encode(["last_page"=>30, "data"=>$data]));

但我的数据存储在 postgres 的数据库表中。 在同一个文件中,我用这个替换了代码,但不起作用

$sql = "SELECT * from cross_reference";
$result = pg_exec($sql);
$data = array();
while($row = pg_fetch_assoc($result)) {
     $data[] = $row;
}
echo (json_encode(["last_page"=>30, "data"=>$data]));

你能帮帮我吗!? 谢谢

【问题讨论】:

    标签: tabulator


    【解决方案1】:

    这取决于两件事,表的设置和从数据库中获取的数据。

    如果您设置了 Tabulator 进行分页,那么您的响应是正确的,如果您没有使用分页,那么您只需要返回 json 编码的 data 变量。

    如果您在问题中发布表定义对象的副本,我可以给出更具体的答案

    【讨论】:

      猜你喜欢
      • 2017-04-09
      • 2012-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多