improved some snippets
This commit is contained in:
parent
ba77d58d08
commit
5271ea5a1d
@ -2,24 +2,72 @@
|
||||
|
||||
# Controller
|
||||
snippet ci_controller
|
||||
class ${1:ClassName} extends CI_Controller {
|
||||
function __construct() {
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class ${1:ClassName} extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
${2:// code...}
|
||||
}
|
||||
|
||||
function ${3:index}() {
|
||||
function ${3:index}()
|
||||
{
|
||||
${4:// code...}
|
||||
}
|
||||
}
|
||||
# Model
|
||||
snippet ci_model
|
||||
class ${1:ClassName_model} extends CI_Model {
|
||||
function __construct() {
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class ${1:ClassName_model} extends CI_Model
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
${2:// code...}
|
||||
}
|
||||
}
|
||||
snippet ci_model_complet
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class ${1:ClassName_model} extends CI_Model
|
||||
{
|
||||
private $table = '${2:table_name}';
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
${2:// code...}
|
||||
}
|
||||
|
||||
public function getRows()
|
||||
{
|
||||
return $this->db->get($table)->result();
|
||||
}
|
||||
|
||||
public function getRow($id)
|
||||
{
|
||||
return $this->db->get_where($table, array('id', $id))->result();
|
||||
}
|
||||
|
||||
public function insert($data)
|
||||
{
|
||||
if($this->db->insert($table, $data))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update($id, $data)
|
||||
{
|
||||
if($this->db->where('id', $id)->update($table, $data))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
# Load view
|
||||
snippet ci_load-view
|
||||
$this->load->view("${1:view_name}", $${2:data});${3}
|
||||
|
Loading…
Reference in New Issue
Block a user