Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2016, 15:15
DesireeC
 
Fecha de Ingreso: febrero-2016
Mensajes: 3
Antigüedad: 8 años, 2 meses
Puntos: 0
mostrar determinados registros de MySql dependiendo si esta activo

Hola a todos nunca he utilizado CodeIgniter y nos llego una aplicación web para hacerle unos cambios, les comento es un simple catálogo de productos con back and front end, tiene sistema de ingreso de productos y los mismos se pueden editar y borrar, ahora se quiere que en el front sólo se muestran los productos que estén activos y no entiendo muy bien como lograr esto con CodeIgniter, en la parte de el modelo

adjunto línea de código

/**
* Add new product
*
* @param array $data product data
*
* @return number
*/
function add($data)
{
if(IS_STORE_DEMO)
{
return true;
}

$data['created_at'] = date('Y-m-d H:i:s');
if ($this->db->insert($this->table_name, $data)) {
return $this->db->insert_id();
}
}

/**
* Fetching all products based on options provided
*
* @param boolean $isArray result in array or object
* @param array $options retriving options
*
* @return object
*/
function fetchAll($isArray = false, $options = null)
{
if ($options != null AND is_array($options)) {
extract($options);
}

$order_type = isset($order_type) ? $order_type : "desc";

if (isset($limit) AND $limit != null) {
$this->db->limit($limit, $offset);
}

if (isset($order_by) AND $order_by != null) {
$this->db->order_by($order_by, $order_type);
}

if (isset($where) AND is_array($where)) {
$this->db->where($where);
}

$query = $this->db->get($this->table_name);

if ($query->num_rows() > 0) {
if ($isArray == true) {
$new_result = $query->result_array();
} else {
$new_result = $query->result();
}

$query->free_result();
return $new_result;
}
}