This site is powered by it.
debug place in mycontroller $this->output->enable_profiler(TRUE);
form dropdown
echo form_dropdown('register_ipn_id', $ipn_options, set_value('register_ipn_id', isset($register['register_ipn_id']) ? $register['register_ipn_id'] : ''), 'Ipn Id')
dbforge
$this->dbforge->add_field($fields);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('ipn');
$fields = array(
'old_name' => array(
'name' => 'new_name',
'type' => 'TEXT',
),
);
$this->dbforge->modify_column('table_name', $fields);
$fields = array(
'preferences' => array('type' => 'TEXT')
);
$this->dbforge->add_column('table_name', $fields);
'user_id' => array(
'type' => 'DECIMAL',
'constraint' => "10,2",
'unsigned' => FALSE,
),
gocart
set sandbox = 0
Config $this->config->item()
Disable $config['enable_hooks'] = FALSE;
don't use
$_SERVER['PATH_INFO']
Can try: $config['indexpage'] = 'index.php'; $config['indexpage'] = 'index.php?';
Session
$this->session->userdata('item');
// returns "" if nothing found
$this->session->set_userdata('some_name', 'some_value');
$this->session->all_userdata()
$this->session->unset_userdata('some_name');
$this->session->flashdata('item');
Upgrading from 2.1.0
replace system folder
replace index.php
replace application/config/mimes.php
ALTER TABLE ci_sessions CHANGE ip_address ip_address varchar(45) default '0' NOT NULL
cms
addons/shared_addons/modules
Place all the contents of your application directory inside the new module.
generate encryption key
openssl rand -hex 16
db
$this->db->select('crash.*, username');
$this->db->from($this->table);
$this->db->join('users', 'user_id = bf_users.id', 'left');
Authorization
https://github.com/ilkon/Tank-Auth
A3M - creates way too many tables
Load Library
$this->load->library('leave_a_message/username');
$username = new Username($name_safe);
Index
$application_folder = dirname(__FILE__).'/application';
Codeigniter wordpress integration
http://www.thedaylightstudio.com/the-whiteboard/2010/06/16/codeigniter-and-wordpress-integration
Bootstrap from Wordpress
https://github.com/lepidosteus/code-igniter-tools/tree/master/dip
// in index
define('STDIN', TRUE);
$_SERVER['argv'] = array();
ob_start();
require(dirname(__FILE__).'/ci/index.php');
ob_end_clean();
global $CI;
$CI = &get_instance();
// in page
$this->load->module('articles/testing');
$CI->load->module('private_chat');
$CI->private_chat->private_chat->comment_feed();
Make sure that codeigniter index.php references application and system folder directly (using $SERVER['DOCUMENTROOT']);
TDD - Unit testing $this->load->library('unit_test'); $this->unit->run(); $this->unit->result();
https://bitbucket.org/kenjis/my-ciunit/
CIUnit
http://d.hatena.ne.jp/Kenji_s/20120117/1326763908
simpletest
https://github.com/ericbarnes/codeigniter-simpletest
Use composer!
Reactor
community driven build and release initiative
Batching email
http://ellislab.com/forums/viewthread/93795/
Raw Database Connection
$this->db->conn_id
Database
return $this->db->query($query)->row_array();
return $this->db->query($query)->row();
return $this->db->query($query)->result();
return $this->db->query($query)->result_array();
$this->db->insert_id();
$this->db->select('crash.*, username');
$this->db->from($this->table);
$this->db->join('users', 'user_id = bf_users.id', 'left');
$query = $this->db->get_where('fun_challenge_card' array('id' => $get_cards_by_challenge_id));
// NOTE!!! this counts as from too
current_url() //requires url helper
CLI
if(!$this->input->is_cli_request())
Set "$active_group" in the config file to "production" or "development"
$this->input->post('test');
$route['category/(:any)/(:any)'] = "category/get_category/$1/$2";
$this->load->helper('url');
redirect();
change: $config['index_page'] = '';
$this->load->vars($data);
Add These Functions to a Model:
function get_content($file_name) {
$this->load->helper('markdown');
$this->load->helper('file');
$path = DATA_PATH . $file_name;
$content = read_file($path);
if ($content == "") {
$content = read_file(DATA_PATH . NOT_FOUND);
}
return markdown($content);
}
function get_links($link_file = "links") {
$this->load->helper('spyc');
return spyc_load_file(DATA_PATH . "$link_file.txt");
}
$this->db->insert('mytable', array(
'text' => $test));
$query = $this->db->get('products');
return $query->result();
$this->db->select('*');
$this->db->from('products');
$this->db->join('clients', 'products.client_id = clients.id');
$query = $this->db->get();
return $query->result();
Parse error: syntax error, unexpected TSTRING, expecting TOLDFUNCTION or TFUNCTION or T_VAR or '}'
Clean up css, embrace the future.
php -r "$(curl -fsSL http://getsparks.org/go-sparks)" php tools/spark help $this->load->spark('restclient/2.0.0'); $this->rest->initialize(array('server' => 'http://twitter.com/'));
$this->load->library('table'); $query = $this->db->get("my_table"); $query->table->generate();
$this->load->library('form_validation');