Created
September 14, 2016 01:16
-
-
Save EdwinPalacios/16316d2974f72cfd524c06629f02b88b to your computer and use it in GitHub Desktop.
Ayudas codeigniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^(.*)$ index.php/$1 [L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Generador de llave encriptada | |
| http://jeffreybarke.net/tools/codeigniter-encryption-key-generator/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if (isset($_SERVER['HTTP_HOST'])){ | |
| $base_url = 'http' . '://' . $_SERVER['HTTP_HOST'] . str_replace(basename($_SERVER['SCRIPT_NAME']) , '', $_SERVER['SCRIPT_NAME']); | |
| $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('BASE_URL', $base_url); | |
| define('BASE_URI', $base_uri); | |
| define('APPPATH_URI', BASE_URI . APPPATH); | |
| unset($base_uri, $base_url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function consulta() { | |
| $data = []; | |
| $this->db->select('campo'); | |
| $query = $this->db->get('tabla'); | |
| if ($query->num_rows() > 0) { | |
| $data = $query->result(); | |
| } else { | |
| $data = false; | |
| } | |
| $query->free_result(); | |
| $this->db->close(); | |
| return $data; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Home_model extends CI_Model { | |
| public function __construct() { | |
| parent::__construct(); | |
| } | |
| public function insert_user() { | |
| //los campos de nuestro formulario ficticio | |
| $campos = ["email", "password", "age"]; | |
| //insertamos los datos en la tabla users con nuestro método form_array pasando los campos | |
| $this->db->insert('users', $this->form_array($campos)); | |
| } | |
| //recorremos todos los campos del array fields y lo devolvemos | |
| private function form_array($fields = [], $post = []) { | |
| foreach ($fields as $key) { | |
| $post[$key] = $this->input->post($key); | |
| } | |
| return $post; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment