Created
February 7, 2012 00:23
-
-
Save onpubcom/1756131 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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