Skip to content

Instantly share code, notes, and snippets.

class Buttons extends CI_Model {
function __construct() {
parent::__construct();
}
function checkDB(){
$result = $this->redis->command('PING');
if($result == 'PONG'){
return true;
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->library('redis');
$this->load->model('Buttons','',TRUE);
}
@glynrob
glynrob / DynamoDB view
Created May 27, 2012 22:21
DynamoDB view
<?php
if(count($members) > 0):
foreach($members as $member => $fields):?>
<h1><a href="<?php echo site_url(array('welcome','view', $fields['id'])); ?>"><?php echo $fields['name']; ?></a>
<a href="<?php echo site_url(array('welcome','edit', $fields['id'])); ?>" style="font-size:12px;">Edit</a> <a href="<?php echo site_url(array('welcome','delete', $fields['id'])); ?>" style="font-size:12px;">Delete</a></h1>
<p><?php echo ($fields['address']); ?><br />
<em>Phone: <?php echo $fields['phone']; ?><br />
Added on <?php echo unix_to_human( $fields['date'] ); ?></em></p>
@glynrob
glynrob / DynamoDB Model
Created May 27, 2012 22:12
DynamoDB Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Model {
protected $primaryKey = 'id';
protected $tableName = 'users';
function __construct() {
parent::__construct();
@glynrob
glynrob / Index function - DynamoDB
Created May 27, 2012 22:10
Index function - DynamoDB
function index()
{
$data = array(
'members' => array()
);
if (!$this->Users->table_exists()){
$this->load->view('no_table', $data);
} else {
$members = $this->Users->getAll(5); // Find all members, limit by 5
if (count($members) != 0){
@glynrob
glynrob / gist:2815896
Created May 27, 2012 21:02
Construtor
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->helper('date');
$this->load->model('Users','',TRUE);
}
@glynrob
glynrob / Welcome Function
Created May 27, 2012 20:59
DynamoDB on Codeigniter
function index()
{
$data = array(
'members' => array()
);
if (!$this->Users->table_exists()){
$this->load->view('no_table', $data);
} else {
$members = $this->Users->getAll(5); // Find all members, limit by 5
if (count($members) != 0){
<?php
if ($allRecords->num_rows() > 0)
{?>
<table cellpadding="4">
<tr>
<td>Name</td>
<td>Email</td>
<td>Phone</td>
</tr>
<?php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cms extends CMS_Controller {
public function index()
{
$this->load->model('Example','',TRUE);
$allRecords = $this->Example->getAll();
$idOne = $this->Example->getById(1);
$data = array(
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Model extends CI_Model {
/** Set this to the table name that the model is mapped to */
protected $tableName;
/** Set this to the primary key of the table for this model.*/
protected $primaryKey;
function __construct() {
parent::__construct();