Ejemplo n.º 1
0
for ($i = 0; $i < 1000; $i++) {
    /* Add another post */
    $post->reset();
    /* reet the post object */
    $post->uri = "/" . uniqid();
    $post->title = "Yet another post ({$i})";
    $post->author = $author->getID();
    $post->save();
}
/* Clean up the current the resultset */
/* same as $post = null; $post = new Post Model */
/* but more efficient */
$post->reset();
$post->where('author', $author->getID());
foreach ($post as $bp) {
    var_dump("Author: " . $bp->author_name);
}
$author->name = "cesar d. rodas";
$author->save();
var_dump("Author profile has been updated");
/** 
 *  List our blog posts in the correct order
 *  (descending by Timestamp).
 */
$post->reset();
$post->columns("title, uri, author_name, author_username, ts");
$post->sort("ts DESC");
$post->limit(PostModel::LIMIT_PER_PAGE);
foreach ($post as $bp) {
    var_dump(array("Author" => $bp->author_name, "Title" => $bp->title));
}