#862: Multiple errors in documentation
-----------------------------------------+----------------------------------
Reporter: [EMAIL PROTECTED] | Owner: david
Type: defect | Status: new
Priority: normal | Milestone:
Component: documentation | Version: 0.11.3
Severity: normal | Keywords:
Has_patch: 0 |
-----------------------------------------+----------------------------------
Going through:
http://agavi.org/docs/tutorial/index.html
Provided SQL for "Bloggie" sample application is wrong. Tables created
are: authors, categories, posts, comments ... but SQL statements in
models refer to "admin_users" instead of "authors". Indexes/keys for
"posts" table fail due to max key length within MySQL, presumably because
the 'title' column is too long.
Code provided for "bloggie" is also incorrect. Provided code is:
/**
* Retrieve 20 last posts.
*
* Selects the post summary, category name and author's screen name
* @return array Array of posts (id, title, posted, author_name,
category_name)
*/
public function findFrontPagePosts()
{
// Obtain the connection identifier from our base class
// This works out to
$this->context->getDatabaseManager()->getConnection()
$conn = $this->getPdo();
$sql = 'SELECT p.id, p.title, p.posted , a.screen_name AS author_name,
c.name AS category_name
FROM posts p
LEFT JOIN admin_users a ON p.author_id = a.id
LEFT JOIN categories c ON p.category_id = c.id
ORDER BY posted DESC LIMIT 20';
return $conn->query($sql)->fetchAll();
}
/**
* Fetch a post by ID
*
* Retrieve a post record by given ID
* @param integer $id ID of the requested post
* @return array Post contents (all post fields, category_name,
author_name)
*/
public function findPostById($id)
{
$conn = $this->getPdo();
$sth = $conn->prepare('SELECT p.*, a.screen_name AS author_name,
c.name AS category_name
FROM posts p
LEFT JOIN admin_users a ON p.author_id = a.id
LEFT JOIN categories c ON p.category_id = c.id
WHERE p.id = ? LIMIT 1');
$sth->execute(array($id));
return $sth->fetch(PDO::FETCH_ASSOC);
}
however PHP/apache's error.log reports getPDO calls as unknown and I had
to substitute in " $conn =
$this->context->getDatabaseManager()->getDatabase()->getConnection(); "
to make sample application work.
--
Ticket URL: <http://trac.agavi.org/ticket/862>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5
_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets