Created
September 30, 2011 17:04
-
-
Save dragoonis/1254361 to your computer and use it in GitHub Desktop.
This file contains 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 APP_Controller_Test extends APP_Controller_Application { | |
function index() { | |
$model = new APP_Model_Test(); | |
$rows = $model->getAllRows(); | |
$data = array('foo' => 'bar', 'user' => 'ppi_user'); | |
$newID = $model->addRow($data); | |
$this->redirect('user/profile/' . $newID); | |
} | |
} |
This file contains 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 | |
// Extends nothing | |
class App_Model_Test { | |
protected $_name = 'users'; // Table name | |
protected $_primary = 'id'; // Table Key | |
protected $_handler = null; | |
function __construct() { | |
$ds = new PPI_DataSource(); | |
$this->_handler = $ds->factory('mysql'); // Name defined in the index.php | |
} | |
function getAllRows() { | |
return $this->_handler->query('select count(*) count from product_views')->fetchAll(); | |
} | |
function addRow(array $data) { | |
$this->_handler->insert($this->_name, $data); | |
return $this->_handler->lastInsertId(); | |
} | |
} |
This file contains 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 | |
require '../ppi/init.php'; | |
// Create a DS reference as 'mysql' | |
PPI_DataSource::add('mysql', array( | |
'type' => 'pdo_mysql', | |
'host' => 'localhost', | |
'dbname' => 'mydb', | |
'user' => 'root', | |
'pass' => 'p4ssw0rd' | |
)); | |
$app = new PPI_App(); | |
$app->siteMode = 'development'; | |
$app->configBlock = 'development'; | |
$app->boot(); | |
$app->dispatch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment