Skip to content

Instantly share code, notes, and snippets.

@fabriziomachado
fabriziomachado / PersonTest.php
Created September 6, 2011 18:11
tests/models/PersonTest.php
<?php
include_once dirname(__FILE__) . '/../support/enviromment.php';
/**
* @group models
*/
class PersonTest extends CIUnit_TestCase {
public function setUp() {
$this->CI->load->spark('php-activerecord/0.0.1');
parent::setUp();
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->spark('php-activerecord/0.0.1');
}
public function index() {
@fabriziomachado
fabriziomachado / phone_carrier_model.php
Created September 6, 2011 12:01
my-ci-app/application/models/phone_carrier_model.php
<?php
class Phone_carrier_model extends CI_Model {
function __construct()
{
parent::__construct();
}
public function getCarriers($attributes)
{
@fabriziomachado
fabriziomachado / phone_carrier_model.php
Created September 6, 2011 12:00
my-ci-app/application/models/phone_carrier_model.php
<?php
class Phone_carrier_model extends CI_Model {
function __construct()
{
parent::__construct();
}
public function getCarriers($attributes)
{
@fabriziomachado
fabriziomachado / database.php
Created September 5, 2011 23:00
application/config/database.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
#$active_group = 'default';
$enviroment = 'default';
if (ENVIRONMENT === 'testing') $enviroment .= '_test';
$active_group = $enviroment;
$active_record = TRUE;
// production enviromment
CREATE TABLE `academico_test`.`phone_carrier` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(150) ,
`txt_address` VARCHAR(150) ,
`txt_message_length` VARCHAR(150) ,
PRIMARY KEY (`id`)
)
ENGINE = MyISAM;
@fabriziomachado
fabriziomachado / deploy.rb
Created August 10, 2011 23:09
Arquivo de configuração do capistrano
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2@rails3' # Or whatever env you want it to run in.
set :rvm_type, :user
# bundler bootstrap
require 'bundler/capistrano'
#ssh_options[:auth_methods] = %w(password keyboard-interactive)
#default_run_options[:pty] = true
@fabriziomachado
fabriziomachado / index.php
Created August 5, 2011 17:31
application/views/peoples/index.php
## conteúdo da view index.php
<h2>application::views::welcome::show</h2>
<h1>Rendering a partials with locals</h1>
<!-- inclui uma partial sem loop, apenas passando variaveis locais -->
<?= render_partial('people/_list_people.php', $locals_vars ); ?>
<h1>Rendering a collection of partials</h1>
<!-- passando uma collection o conteúdo da partial é inserida a cada linha do loop -->
<?= render_partial('people/_people.php',
@fabriziomachado
fabriziomachado / peoples.php
Created August 5, 2011 17:25
application/controllers/peoples.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class People extends MY_Controller {
function __construct() {
parent::__construct();
}
function index()
{
@fabriziomachado
fabriziomachado / partials_helper.php
Created August 5, 2011 12:45
application/helpers/partials_helper.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function render_partial($partial, $locals = null, $collection = null, $ajax = NULL) {
$partial = APPPATH .'views/'. $partial;
$contents = '';
foreach($locals AS $key => $value) {
${$key} = $value;