1
Hello!
I’m using dataTable
in codeigniter and performing a query through the field search
Seeing the query below, it works well when it comes to query within the same table tb_pagamento
.
Now I want to query the operator name in this same query. However, in the table tb_pagamento
I only have the operator ID (operador_id
), where the operator name is in the table tb_operador
tb_operator
'id'
'name'
See the consultation:
var $tabela = 'tb_pagamento';
var $tb_operador = 'tb_operador';
var $column_order = array('id', 'empresa', null);
var $column_search = array('id', 'empresa', 'nome_cliente', 'dt_pagamento', 'valor_pagamento', 'operador_id');
var $order = array('id' => 'asc');
private function get_query() {
$this->db->from($this->tabela);
$i = 0;
foreach ($this->column_search as $item) {
if($_POST['search']['value']) {
if($i === 0) {
$this->db->group_start();
$this->db->like($item, $_POST['search']['value']);
} else {
$this->db->or_like($item, $_POST['search']['value']);
}
if(count($this->column_search) - 1 == $i){
$this->db->group_end();
}
}
$i++;
}
if(isset($_POST['order'])) {
$this->db->order_by($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
} else if(isset($this->order)) {
$order = $this->order;
$this->db->order_by(key($order), $order[key($order)]);
}
}
It really worked, thank you.
– Wagner Fillio