我的自定义表中有两条记录。我正在尝试使用SELECT COUNT(*) AS total FROM tableA
但我没有得到我所期望的结果。
下面的代码将回显Array ( [0] => Array ( [total] => 2 ) )
:
// Count the amount of records in the table
$total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", \'ARRAY_A\' );
echo "Total Records:" . print_r( $total );
下面的代码没有任何回应:// Count the amount of records in the table
$total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", \'ARRAY_A\' );
echo "Total Records:" . $total[0][\'total\'];
如何简化此操作?我做错了什么?我为此绞尽脑汁,但我就是无法让它发挥作用。