Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/1d81d3cc6ead9e44bb825bf8c8499236 to your computer and use it in GitHub Desktop.
Save parzibyte/1d81d3cc6ead9e44bb825bf8c8499236 to your computer and use it in GitHub Desktop.
<?php
class HolaMundo extends CI_controller{
public function listar(){
# Cargar el modelo a $this
$this->load->model('HolaMundoModel');
# Ahora el modelo está en $this como una propiedad
# Todo esto le pasaremos a la vista
$datos = array();
# Ponemos el título...
$datos["titulo"] = "¡Título desde el controlador!";
# Cargar la lista
$datos["lista"] = $this->HolaMundoModel->obtenerLista();
# Renderizar y pasar datos.
# Tip: no es necesario pasar la extensión del archivo de la vista (sería hola.php)
$this->load->view("hola", $datos);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment