Skip to content

Instantly share code, notes, and snippets.

@dittos
Created August 6, 2010 13:14
Show Gist options
  • Save dittos/511303 to your computer and use it in GitHub Desktop.
Save dittos/511303 to your computer and use it in GitHub Desktop.
<?php
require_once 'Ponytail/Model.php';
require_once 'Ponytail/Shortcuts.php';
$urls = array(
'^$' => 'index.php#index',
'^(?P<id>[0-9]+)$' => 'article_detail',
);
$config = array();
$config['db_backend'] = 'sqlite3';
$config['db_host'] = '';
$config['db_name'] = 'test.db';
function article_detail($request) {
$article = $request->db->select(Article::get($request->url['id']));
return render('article_detail.html', array(
'article' => $article
), $request);
}
<?php
class Board {
function Board($data) {
// ... initializes object with data ...
$this->articles = Q('article')->filter(array('board_id' => $this->id));
}
}
class Article {
static function all() { return Q('article'); }
static function get($id) { return self::all()->get('id', $id); }
}
$db->update(Article::all(), array('notice' => true));
$notices = $db->select($board->articles->filter('notice'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment