我的“会员”数据库中有3个表,其中包含有关其所属成员名称和团队的信息。我正在尝试构建2个插件。
One that lists all of my members, with the exception of a "master" member
which is a member of all teams. with the ability to bulk add or delete to
or from a team.
The second is a list of all teams, with the ability to bulk add or delete
to or from a members profile.
“members”具有成员名称。它还包含一个“主”成员,拥有所有团队的成员资格。它还包含其余成员。
“团队”包含所有团队信息
“members_team”包含成员的ID,并将这些ID连接到与团队关联的ID。每个团队协会一排。
我一直在试验我将在下面添加的现有代码。此时我甚至无法显示表格的内容,更不用说进入批量编辑了。当它与我的编辑一起运行时,我不断得到一个空表或错误。
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class Members_List extends WP_List_Table {
/** Class constructor */
public function __construct() {
parent::__construct( [
'singular' => __( 'member', 'sp' ), //singular name of the listed records
'plural' => __( 'members', 'sp' ), //plural name of the listed records
'ajax' => false //does this table support ajax?
] );
}
/**
* Retrieve members data from the database
*
* @param int $per_page
* @param int $page_number
*
* @return mixed
*/
public static function get_members( $per_page = 5, $page_number = 1 ) {
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}name";
if ( ! empty( $_REQUEST['orderby'] ) ) {
$sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] );
$sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC';
}
$sql .= " LIMIT $per_page";
$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
$result = $wpdb->get_results( $sql, 'ARRAY_A' );
return $result;
}