[Plugin: Custom List Table Example] Help using plugin (error message with sql instead of example $da
-
I’ve installed the plugin and it works great with the example data.
However, when I try to use my own sql in the prepare_items function I am getting an error:
Fatal error: Cannot use object of type stdClass as arrayIt seems like the example data is an array that contains arrays
i.e.var $example_data = array( array( 'ID' => 1, 'title' => '300', 'rating' => 'R', 'director' => 'Zach Snyder' ), array( 'ID' => 2, 'title' => 'Eyes Wide Shut', 'rating' => 'R', 'director' => 'Stanley Kubrick' ),But when I write:
global $wpdb; $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name'; //If no sort, default to title $sql = "SELECT * FROM wp_nc_location ORDER BY " . $orderby; $data = $wpdb->get_results($sql);My $data is an array that contains objects, print_r and gettype on $data reveals
data is Array ( [0] => stdClass Object ( …) [1] => stdClass Object ( …) )
Can anyone help?
http://ww.wp.xz.cn/extend/plugins/custom-list-table-example/
The topic ‘[Plugin: Custom List Table Example] Help using plugin (error message with sql instead of example $da’ is closed to new replies.