Tenho a query usada no WP e ela causa um erro quando uso OR, segue o exemplo do uso:
SELECT * FROM ' . $table_ucf . ' WHERE form LIKE "'. $this->form_active.'" AND name LIKE "%s" OR email LIKE "%s"
se eu tirar a condição depois do OR funciona, exemplo:
SELECT * FROM ' . $table_ucf . ' WHERE form LIKE "'. $this->form_active.'" AND name LIKE "%s"
EDIT:
function getDBData(){
global $wpdb;
$table_ucf = $wpdb->prefix . 'ucf';
//var_dump($this->table_search);
if ($this->table_search) {
$like = '%' . $wpdb->esc_like($this->table_search) . '%';
$form_data = $wpdb->get_results(
$wpdb->prepare(
'SELECT * FROM ' . $table_ucf . ' WHERE form LIKE "'. $this->form_active.'" AND name LIKE "%s" OR email LIKE "%s"',
$like
)
, ARRAY_A);
} else {
$form_data = $wpdb->get_results(
$wpdb->prepare(
'SELECT * FROM ' . $table_ucf . ' ucf WHERE ucf.form = %s',
$this->form_active,
'%' . $wpdb->esc_like($this->table_search) . '%'
)
, ARRAY_A);
}
$this->example_data = $form_data;
}
EDIT: Ele dá um erro numa párte mais abaixo do código;
Warning: array_slice() expects parameter 1 to be array, null given in C:\xampp\htdocs\ekantika\wp-content\plugins\ucf\dx.ucf.table.php on line 237
Essa é a parte do código, linha 221 até a linha 244
function prepare_items() {
$this->process_bulk_action();
$this->getDBData();
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
@usort($this->example_data, array(&$this, 'usort_reorder'));
$per_page = 50;
$current_page = $this->get_pagenum();
$total_items = count($this->example_data);
// only ncessary because we have sample data
$this->found_data = array_slice($this->example_data, (($current_page - 1) * $per_page), $per_page);
$this->set_pagination_args(array(
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $per_page //WE have to determine how many items to show on a page
));
$this->items = $this->found_data;
}
sprintf()
ele vai reclamar que falta um argumento, pode colocar a chamada dessa consulta?