Skip to content
Snippets Groups Projects
Commit 64decd6a authored by Eborio's avatar Eborio
Browse files

Merge

parents 843638b3 89ed8498
No related branches found
No related tags found
No related merge requests found
Showing
with 756 additions and 1 deletion
<ifModule mod_rewrite.c>
# ----------------------------------------------------------------------
<<<<<<< HEAD
# Activar el ModRewrite
=======
# Activate Rewrite Engine
>>>>>>> 89ed8498e0311cbf5c6876c877116323d46d4dac
# ----------------------------------------------------------------------
RewriteEngine on
 
# ----------------------------------------------------------------------
<<<<<<< HEAD
# Borrar el index.php de las URL's
# Debes especificar los archivos de assets que poseas dentro de tu
# aplicacion
Loading
Loading
@@ -14,10 +19,19 @@
#
# ó
#
=======
# Delete the index.php from URL's
# Especify the necesary directories or files depending of your
# necesities.
# Example:
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|assets)
# or
>>>>>>> 89ed8498e0311cbf5c6876c877116323d46d4dac
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|css|js|img)
# ----------------------------------------------------------------------
RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]
<<<<<<< HEAD
</ifModule>
 
# Si tienes problemas con el .htaccess anterior prueba con el siguiente
Loading
Loading
@@ -28,4 +42,7 @@
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php/$1 [L]
# -------------------------------------------------------------------------
\ No newline at end of file
# -------------------------------------------------------------------------
=======
</ifModule>
>>>>>>> 89ed8498e0311cbf5c6876c877116323d46d4dac
# Primeros pasos
Comenzamos nuestro trabajo con el framework. Accedemos por primera vez a la instalación de CodeIgniter desde el navegador y vemos la vista de bienvenida que posee por defecto la instalación.
En primer lugar aprendemos a cambiar el entorno de trabajo mediante el `index.php`.
Modificamos la vista de bienvenida `welcome_message.php` y el controlador `welcome`.
Ademas aprendemos la manera correcta de nombrar un controlador, tanto la clase como el archivo que la contiene siguiendo la guía de estilos de CodeIgniter, así como configurar el controlador por defecto mediante el archivo `routes.php`.
**Importante:** Debes aprender de que manera llamar a los controladores y métodos desde la URL ya que es la única forma de acceder a ellos.
**NOTA IMPORTANTE:** CodeIgniter requiere un archivo `.htaccess` para eliminar el `index.php` de la URL y para que los redireccionamientos funcionen correctamente. En este repositorio se encuentra dicho archivo para que lo utilices en tus proyectos.
## Lecturas recomendadas
- [Importancia del archivo .htaccess](http://todoprogramacion.com.ve/articulos/apache/importancia-del-archivo-htaccess)
- [Generar URL's limpias con CodeIgniter](http://todoprogramacion.com.ve/articulos/codeigniter/generar-urls-limpias-con-codeigniter)
\ No newline at end of file
# Configuración de CodeIgniter
En este video configuramos el lenguaje español en nuestra instalación de CodeIgniter. El paquete de idiomas usado en el videotutorial ya no está disponible en la actualidad, pero pueden encontrar un paquete mejorado en [este fork](https://github.com/eborio/CodeIgniter-Spanish-Pack) realizado por mi.
Si desean el paquete original desde donde realicé el fork lo pueden encontrar en [este repositorio](https://github.com/rasec/CodeIgniter-Spanish-Pack).
También utilizamos el archivo constants.php para evitar configurar de manera manual nuestra URL base.
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0777);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
// Base URL (keeps this crazy sh*t out of the config.php
if (isset($_SERVER['HTTP_HOST'])) {
$base_url = 'http'
. '://' . $_SERVER['HTTP_HOST']
. str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
// Base URI (It's different to base URL!)
$base_uri = parse_url($base_url, PHP_URL_PATH);
if (substr($base_uri, 0, 1) != '/')
$base_uri = '/' . $base_uri;
if (substr($base_uri, -1, 1) != '/')
$base_uri .= '/';
}
else {
$base_url = 'http://localhost/';
$base_uri = '/';
}
// Define these values to be used later on
define('BASE_URL', $base_url);
define('BASE_URI', $base_uri);
define('APPPATH_URI', BASE_URI . APPPATH);
// We dont need these variables any more
unset($base_uri, $base_url);
/* End of file constants.php */
/* Location: ./application/config/constants.php */
\ No newline at end of file
# Aplicación Dinámica Sencilla (Parte I)
En este video iniciamos el desarrollo de un apalicación dinámica sencilla (Blog funcional) para irnos adaptando al trabajo con el framework. Para ello iniciamos creando la base de datos a utilizar con WorkBench para ahorrarnos cierto trabajo y evitar errores. También utilizaremos una instalación limpia de CodeIgniter.
Aquí encontraran tanto el archivo aplicación.mwb que les permitirá visualizar y modificar el modelo entidad-relación utilizando WorkBench, como el archivo aplicación.sql que contiene las sentencias SQL necesarias para crear la base de datos sin necesidad de emplear la aplicación de Oracle.
\ No newline at end of file
File added
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `aplicacion` DEFAULT CHARACTER SET latin1 ;
USE `aplicacion` ;
-- -----------------------------------------------------
-- Table `aplicacion`.`categorias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `aplicacion`.`categorias` (
`id_categoria` INT(11) NOT NULL AUTO_INCREMENT,
`nombre_categoria` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id_categoria`))
ENGINE = InnoDB
AUTO_INCREMENT = 3
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `aplicacion`.`articulos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `aplicacion`.`articulos` (
`id_articulo` INT(11) NOT NULL AUTO_INCREMENT,
`nombre_articulo` VARCHAR(100) NULL DEFAULT NULL,
`contenido_articulo` TEXT NULL DEFAULT NULL,
`fecha_articulo` DATE NULL DEFAULT NULL,
`keywords` VARCHAR(100) NULL,
`id_categoria` INT(11) NOT NULL,
PRIMARY KEY (`id_articulo`),
INDEX `fk_articulos_categorias_idx` (`id_categoria` ASC),
CONSTRAINT `fk_articulos_categorias`
FOREIGN KEY (`id_categoria`)
REFERENCES `aplicacion`.`categorias` (`id_categoria`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 9;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
\ No newline at end of file
<ifModule mod_rewrite.c>
# ----------------------------------------------------------------------
# Activate Rewrite Engine
# ----------------------------------------------------------------------
RewriteEngine on
# ----------------------------------------------------------------------
# Delete the index.php from URL's
# Especify the necesary directories or files depending of your
# necesities.
# Example:
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|assets)
# or
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|css|js|img)
# ----------------------------------------------------------------------
RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]
</ifModule>
\ No newline at end of file
# Aplicación Dinámica Sencilla (Parte II)
Continuamos desarrollando nuestra aplicación. Creamos el controlador `home.php` que se encargará de procesar las solicitudes de la aplicación. También debemos configurar que sea el controlador por defecto en el archivo `routes.php`.
Por otra parte creamos el modelo para interactuar con la base de datos, en específico `articulos_model.php` y dentro de el ubicamos el método `lista_articulos()` que obtendrá el listado completo de los artículos.
Este modelo es instanciado o llamado dentro del controlador `home.php` donde también vimos la forma de cambiar el nombre de objeto del modelo a uno diferente. Lógicamente para ello debemos cargar la librería `database` lo cual hacemos en el archivo `routes.php`.
Finalmente enviamos los datos de manera dinámica a la vista `index.php` y hacemos un `foreach` dentro de ella para mostrarlos.
## Directorios del repositorio
`config`: posee los archivos `autoload.php` y `routes.php` configurados de la misma manera que en el video.
`controllers`: contiene el controlador `home.php`.
`models`: posee el modelo `articulos_model.php`.
`views`: contiene la vista `index.php` utilizada para mostrar el listado de artículos obtenida desde la base de datos.
Finalmente se incluye el archivo `.htaccess`.
**Nota:** Tanto el controlador, como el modelo y la vista poseen comentarios con los códigos alternativos utilizados.
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Helper files
| 4. Custom config files
| 5. Language files
| 6. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packges
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database');
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file. For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['model'] = array('model1', 'model2');
|
*/
$autoload['model'] = array();
/* End of file autoload.php */
/* Location: ./application/config/autoload.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There area two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/
$route['default_controller'] = "home";
$route['404_override'] = '';
/* End of file routes.php */
/* Location: ./application/config/routes.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Clase Home
*
* Controlador para manejar todas las solicitudes relacionadas
* con los articulos
*
* @author Eborio Linarez <contacto@todoprogramacion.com.ve>
* @link http://todoprogramacion.com.ve
*/
class Home extends CI_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Cargar un modelo de manera basica
$this->load->model('Articulos_model');
// Cargar un modelo cambiando el nombre del objeto
// $this->load->model('Articulos_model','art');
}
/**
* Muestra la vista principal con el listado de articulos
*
* @return view Vista principal
*/
public function index()
{
// Se obtiene la lista de articulos
$datos['articulos'] = $this->Articulos_model->lista_articulos();
// Utilizacion del modelo a traves del nombre de objeto modificado
// $datos['articulos'] = $this->art->lista_articulos();
$datos['titulo'] = 'Título de mi sitio - Curso de CI';
$this->load->view('index',$datos);
}
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Clase Articulos_model
*
* Modelo para interactuar con los datos de los articulos
*
* @author Eborio Linarez <contacto@todoprogramacion.com.ve>
* @link http://todoprogramacion.com.ve
*/
class Articulos_model extends CI_Model
{
/**
* Obtiene el listado de articulos
*
* @return object Datos de los articulos
*/
public function lista_articulos()
{
$this->db->order_by('id_articulo', 'desc');
$consulta = $this->db->get('articulos');
return $consulta->result();
// Retornar los datos en forma de arreglo
// return $consulta->result_array();
}
}
/* End of file articulos_model.php */
/* Location: ./application/models/articulos_model.php */
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title><?php echo $titulo;?></title>
</head>
<body>
<h1>Aplicación Dinámica con CodeIgniter</h1>
<?php foreach ($articulos as $item): ?>
<h3>
<?php
echo $item->nombre_articulo;
// Mostrar datos devueltos por el modelo mediante result_array()
// echo $item['nombre_articulo'];
?>
</h3>
<strong>Fecha de Publicación:</strong> <?php echo $item->fecha_articulo;?>
<p>
<?php echo $item->contenido_articulo;?>
</p>
<hr>
<?php endforeach;?>
</body>
</html>
\ No newline at end of file
<ifModule mod_rewrite.c>
# ----------------------------------------------------------------------
# Activate Rewrite Engine
# ----------------------------------------------------------------------
RewriteEngine on
# ----------------------------------------------------------------------
# Delete the index.php from URL's
# Especify the necesary directories or files depending of your
# necesities.
# Example:
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|assets)
# or
# RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml|css|js|img)
# ----------------------------------------------------------------------
RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]
</ifModule>
\ No newline at end of file
# Aplicación Dinámica Sencilla (Parte III)
Finalizamos nuestra aplicación dinámica sencilla. Ahora nos ocupamos de brindar un mecanismo para mostrar los detalles o información completa de cada artículo. Para conseguirlo necesitamos crear un enlace en la vista `index.php` utilizando para ello el `helper URL` y el `helper Text`, los cuales cargamos en nuestro `autoload.php`. También es necesario crear la ruta correspondiente en el archivo `routes.php`.
Desarrollamos tres versiones diferentes para la consulta de los detalles del artículo:
- Mediante el ID del artículo
- Mediante el nombre del artículo
- Mediante la URL del artículo (método recomendado)
Para la versión de consulta mediante la URL, necesitamos también crear un ruta diferente en nuestro `routes.php` así como un campo nuevo en la base de datos.
## Directorios del repositorio
`config`: posee los archivos `autoload.php` y `routes.php` configurados de la misma manera que en el video.
`controllers`: contiene el controlador `home.php`.
`models`: posee el modelo `articulos_model.php`.
`views`: contiene las vistas `index.php` y `detalle.php`.
**Nota:** Tanto el controlador, como el modelo, la vistas y el archivo de ruteo poseen comentarios con los códigos alternativos utilizados.
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Helper files
| 4. Custom config files
| 5. Language files
| 6. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packges
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database');
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url','text');
/*
| -------------------------------------------------------------------
| Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file. For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['model'] = array('model1', 'model2');
|
*/
$autoload['model'] = array();
/* End of file autoload.php */
/* Location: ./application/config/autoload.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There area two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/
$route['default_controller'] = "home";
$route['404_override'] = '';
// $route['articulo/(:num)/:any'] = 'home/detalle_articulo/$1';
$route['articulo/(:any)'] = 'home/detalle_articulo/$1';
/* End of file routes.php */
/* Location: ./application/config/routes.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Articulos_model');
// Cargar un modelo cambiando el nombre del objeto
// $this->load->model('Articulos_model','art');
}
// Muestra la vista principal con el listado de articulos
function index() {
$datos['articulos'] = $this->Articulos_model->lista_articulos();
// Utilizacion del modelo a traves del nombre de objeto modificado
// $datos['articulos'] = $this->art->lista_articulos();
$datos['titulo'] = 'Título de mi sitio - Curso de CI';
$this->load->view('index',$datos);
}
// Muestra un articulo por URL
function detalle_articulo($url_articulo) {
$url_limpio = $this->security->xss_clean($url_articulo);
$datos['detalle'] = $this->Articulos_model->detalle_articulo($url_limpio);
$datos['titulo'] = $datos['detalle']->url_articulo;
$this->load->view('detalle',$datos);
}
// Muestra un articulo por nombre
// function detalle_articulo($nombre_articulo) {
// $nombre_limpio = str_replace('-', ' ', $nombre_articulo);
// $datos['detalle'] = $this->Articulos_model->detalle_articulo($nombre_limpio);
// $datos['titulo'] = $datos['detalle']->nombre_articulo;
// $this->load->view('detalle',$datos);
// }
// Muestra los detalles de un articulo por ID
// function detalle_articulo($id_articulo) {
// $id_limpio = $this->security->xss_clean($id_articulo);
// $datos['detalle'] = $this->Articulos_model->detalle_articulo($id_limpio);
// $datos['titulo'] = $datos['detalle']->nombre_articulo;
// $this->load->view('detalle',$datos);
// }
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
\ No newline at end of file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Articulos_model extends CI_Model {
// Genera el listado de articulos
function lista_articulos() {
$this->db->order_by('id_articulo', 'desc');
$consulta = $this->db->get('articulos');
return $consulta->result();
// Retornar los datos en forma de arreglo
// return $consulta->result_array();
}
// Genera los detalles de un articulo por su URL
function detalle_articulo($url_articulo) {
$this->db->where('url_articulo', $url_articulo);
$consulta = $this->db->get('articulos');
return $consulta->row();
}
// Genera los detalles de un articulo por su nombre
// function detalle_articulo($nombre_articulo) {
// $this->db->where('nombre_articulo', $nombre_articulo);
// $consulta = $this->db->get('articulos');
// return $consulta->row();
// }
// Genera los detalles de un articulo por ID
// function detalle_articulo($id_articulo) {
// $this->db->where('id_articulo', $id_articulo);
// $consulta = $this->db->get('articulos');
// return $consulta->row();
// }
}
/* End of file articulos_model.php */
/* Location: ./application/models/articulos_model.php */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment