Skip to content

Instantly share code, notes, and snippets.

@onpubcom
Created February 7, 2012 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onpubcom/1756131 to your computer and use it in GitHub Desktop.
Save onpubcom/1756131 to your computer and use it in GitHub Desktop.
<?php
include 'onpub/api/onpubapi.php';
// Establish the connection to the Onpub database.
$pdo = new PDO("mysql:host=localhost;dbname=test", "test", "test");
$oArticles = new OnpubArticles($pdo);
$qo = new OnpubQueryOptions();
$qo->orderBy = 'created';
$qo->order = 'DESC';
$qo->rowLimit = 10;
// Select 10 articles from section 2 sorted by date created in descending order.
$articles = $oArticles->select($qo, 2);
// Print the title of each article in a bulleted list.
echo '<ul>';
foreach ($articles as $a) {
echo '<li>' . $a->title . '</li>';
}
echo '</ul>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment