Created
August 6, 2010 13:14
-
-
Save dittos/511303 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 | |
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); | |
} |
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 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