Hello
I am using dataTable
in codeigniter and doing a query through the search
Looking at the query below, it works fine when it comes to query within the same table tb_pagamento
.
Now I want to query the name of the operator in the same query. However, in the tb_pagamento
table I only have the operator ID ( operador_id
), where the operator name is in the tb_operador
tb_operator
'id'
'name'
See the query:
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)]);
}
}