<?php
namespace Modules\Cad_pixel\Models;

use App\Models\BaseModel;

class Model_cad_pixel extends BaseModel {
	public function getCadastros() {
		$table 		= "cad_pixel";
		$builder  = $this->db->table($table);
		$query    = $builder->get();

		return $query->getResult();
	}

	public function cadastrando() {
		$table 		= "cad_pixel";
		$builder  = $this->db->table($table);
		$query    = $builder->insert($_POST);

		return $this->db->insertID();
	}

	public function alterar($id) {
		$table 		= "cad_pixel";
		$builder  = $this->db->table($table)->where('id', $id);
		$query    = $builder->get();

		return $query->getRow();
	}

	public function alterando($id) {
		$table 		= "cad_pixel";
		$builder  = $this->db->table($table);
		
		$builder->set('data_alteracao', date("Y-m-d H:i:s"));
		$builder->where('id', $id);
		$builder->update($_POST);

		return $id;
	}

	public function deletar($id) {
		$table 		= "cad_pixel";
		$builder  = $this->db->table($table);
		
		$builder->where('id', $id);
		$builder->delete();
	}
}