· 8 years ago · Dec 21, 2017, 02:44 PM
1$objeto = $_POST['objeto'];
2$objeto_decode = json_decode($objeto);
3$id = $objeto_decode->id;
4$boleto_empresa = $objeto_decode->boleto_empresa;
5// subindo model
6$this->boleto->atualizar_boleto_empresa($boleto_empresa, $id);
7
8Array
9(
10 [0] => stdClass Object
11 (
12 [empresa_id] => 2
13 )
14 [1] => stdClass Object
15 (
16 [empresa_id] => 4
17 )
18)
19
20/*** atualizar boleto empresa ***/
21public function atualizar_boleto_empresa($dados)
22{
23 $array = (array) $dados;
24 foreach ($dados as $bol_emp)
25 {
26 $boleto_empresa = [
27 'empresa_id' => $bol_emp->empresa_id,
28 ];
29 $this->db->replace($this->tbl_boleto_empresa, $boleto_empresa);
30 }
31}
32
33-- -----------------------------------------------------
34-- Table `tbl_boleto_empresa`
35-- -----------------------------------------------------
36DROP TABLE IF EXISTS `tbl_boleto_empresa`;
37CREATE TABLE IF NOT EXISTS `tbl_boleto_empresa` (
38 `id` INT(11) NOT NULL AUTO_INCREMENT,
39 `empresa_id` INT(11) NULL DEFAULT 0,
40 `boleto_id` INT(11) NULL DEFAULT 0,
41 PRIMARY KEY (`id`))
42ENGINE = InnoDB
43DEFAULT CHARSET = utf8;