本文整理汇总了PHP中Book::fromMySql方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::fromMySql方法的具体用法?PHP Book::fromMySql怎么用?PHP Book::fromMySql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::fromMySql方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_rss
function create_rss($search, $limit)
{
$title = 'uBook';
if ($search) {
$title .= ' - Suche nach "' . $search . '"';
}
$link = WEBDIR;
$desc = 'Neue Angebote bei uBook.';
$lang = 'de-de';
$copyright = 'uBook';
$rss = new RssChannel($title, $link, $desc, $lang, $copyright);
$imageUrl = 'http://ubook.asta-bielefeld.de/ubook_small.gif';
$rss->addImage($imageUrl, $title, $link);
$query = BookQuery::searchQuery($search);
$query .= ' order by created desc';
if ($limit > 0) {
$query .= ' limit ' . $limit;
}
$mysqlResult = mysql_query($query);
while ($book = Book::fromMySql($mysqlResult)) {
$title = $book->get('title');
$desc = 'Neues Buchangebot:' . "\n" . $book->asText();
$desc = nl2br(Parser::text2html($desc));
$id = $link = WEBDIR . 'book.php?id=' . $book->get('id');
$author = 'ubook@asta-bielefeld.de (uBook-Team)';
$date = $book->get('created');
$rss->addItem($id, $title, $desc, $link, $author, $date);
}
return $rss;
}
示例2: send
/**
* Sends an E-Mail to the offerer of the book.
*
* Known usages:
* - add.php
* - book.php - "Anfrage: "
* - Cleaner.php - "Erneuern: "
*
* @param int $bookId database id of th book, this mail is about
* @param string $subjectStart beginning of the subject, the title will
* follow
* @param string $message some text for the user, greeting will be added
* @param string $replyTo mail address for the Reply-To field (optional)
* @return bool false on failure
*/
public static function send($bookId, $subjectStart, $message, $replyTo = null)
{
include_once 'mysql_conn.php';
$query = 'select mail, id, author, title, price, year, isbn,' . ' description, auth_key from books where id="' . $bookId . '"';
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
return false;
}
$book = Book::fromMySql($result);
$subject = $subjectStart . $book->get('title');
$tmpl = Template::fromFile('view/mail.txt');
$tmpl->assign('message', $message);
$tmpl->assign('bookText', $book->asText());
if ($replyTo == null || $replyTo == $book->get('mail')) {
$subTmpl = $tmpl->addSubtemplate('editBook');
$link = self::editLink($book->get('id'), $book->get('auth_key'));
$subTmpl->assign('editLink', $link);
$books = new UsersBooks($book->get('mail'));
$subTmpl->assign('usersBooks', $books->toString());
} else {
$subTmpl = $tmpl->addSubtemplate('viewBook');
$link = self::bookLink($book->get('id'));
$subTmpl->assign('bookLink', $link);
}
$content = $tmpl->result();
return self::mail($book->get('mail'), $subject, $content, $replyTo);
}
示例3: query
public static function query(Isbn $isbn)
{
include_once 'mysql_conn.php';
$fields = array('author', 'title', 'price', 'year', 'isbn', 'description');
$query = 'select ' . implode(', ', $fields) . ' from books where isbn="' . $isbn->toString() . '"' . ' order by price;';
$result = mysql_query($query);
$book = Book::fromMySql($result);
if (!$book) {
return null;
}
while ($b = Book::fromMySql($result)) {
$isComplete = true;
foreach ($fields as $field) {
if ($book->get($field)) {
continue;
}
if ($b->get($field)) {
$book->set($field, $b->get($field));
continue;
}
$isComplete = false;
}
if ($isComplete) {
break;
}
}
return $book;
}
示例4: getList
public function getList()
{
$mysqlResult = parent::getMysqlResult();
$bookScriptUrl = WEBDIR . 'book.php';
$list = array();
while ($book = Book::fromMySql($mysqlResult)) {
$url = $bookScriptUrl . '?id=' . $book->get('id');
$extBook = new ExternalBook($url, $book->get('author'), $book->get('title'), $book->get('price'));
$list[] = $extBook;
}
return $list;
}
示例5: toHtmlRows
public function toHtmlRows()
{
$template = new Template('<tr><td><a href="book.php?id=\'id\'">' . '<!-- begin author -->\'author\': <!-- end author -->' . '\'title\'</a></td>' . '<td>\'price\' €</td></tr>' . "\n");
$html = '';
while ($book = Book::fromMySql($this->getMysqlResult())) {
$t = clone $template;
$book->assignHtmlToTemplate($t);
if ($book->get('author')) {
$t->addSubtemplate('author');
}
$html .= $t->result();
}
return $html;
}
示例6: UsersBooks
/**
* Queries the book list from the database and stores it.
* @param $userMail A valid mail address. Quits if none given.
* @return UsersBooks
*/
function UsersBooks($userMail)
{
if (!$userMail) {
exit;
}
$query = 'select
id, author, title, price, year, description, auth_key
from books where mail="' . addslashes($userMail) . '"
order by author, title, price';
$bookListResult = mysql_query($query);
$this->bookCount = mysql_num_rows($bookListResult);
$listString = "\n";
while ($book = Book::fromMySql($bookListResult)) {
$listString .= "\n";
$listString .= $book->get('author') . ': ' . $book->get('title') . "\n";
$listString .= Mailer::editLink($book->get('id'), $book->get('auth_key')) . "\n";
}
$this->bookListString = $listString;
}
示例7: SelectableCategories
$error = 'not found';
} else {
/* we have valid access to this book */
$selectableCategories = new SelectableCategories($id);
if (isset($_POST['author'])) {
/* update base book data */
$query = 'update books set
author = "' . $_POST['author'] . '",
title = "' . $_POST['title'] . '",
year = "' . $_POST['year'] . '",
isbn = "' . $_POST['isbn'] . '",
price = "' . str_replace(',', '.', $_POST['price']) . '",
description = "' . $_POST['desc'] . '"
where id="' . $id . '" and auth_key="' . $key . '"';
mysql_query($query);
/* update category relations */
$selectableCategories->update();
/* update expire date and look at the book */
require 'renew.php';
}
$book = Book::fromMySql($result);
require_once 'tools/Output.php';
require_once 'text/Template.php';
$tmpl = Template::fromFile('view/edit.html');
$book->assignHtmlToTemplate($tmpl);
assignSelectableCategories($selectableCategories, $tmpl);
$tmpl->assign('id', $_GET['id']);
$tmpl->assign('key', $_GET['key']);
$output = new Output();
$output->send($tmpl->result());
}
示例8: selectBook
private function selectBook($bookId)
{
$result = mysql_query('select id, author, title, year, price, isbn,' . ' description, auth_key, mail from books where id="' . $bookId . '"');
if (mysql_num_rows($result) != 1) {
$this->tmpl->addSubtemplate('messageNotFound');
$this->output->sendNotFound($this->tmpl->result());
exit;
}
return Book::fromMySql($result);
}