Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## db.xml [html]
- <?xml version="1.0"?>
- <schema version="0.3">
- <table name="btLatestGuestbookEntries">
- <field name="bID" type="I">
- <key />
- <unsigned />
- </field>
- <field name="title" type="X2">
- </field>
- <field name="num" type="I">
- <unsigned />
- </field>
- </table>
- </schema>
- ## add.php [php]
- <?php echo $form->label('title', t('Title'));?>
- <?php echo $form->text('title', array('style' => 'width: 320px'));?>
- <?php echo $form->label('num', t('Number of entries'));?>
- <?php echo $form->text('num', array('style' => 'width: 3em'));?>
- ## controller.php [php]
- <?php
- class LatestGuestbookEntriesBlockController extends BlockController {
- var $pobj;
- protected $btDescription = "Shows the latest guestbook entries.";
- protected $btName = "Latest Guestbook Entries";
- protected $btTable = 'btLatestGuestbookEntries';
- protected $btInterfaceWidth = "350";
- protected $btInterfaceHeight = "300";
- function getTitle() {
- return $this->title;
- }
- function getEntries($num = 3) {
- $db = Loader::db();
- if($this->num) {
- $limit = " LIMIT {$this->num}";
- }
- $query = "SELECT entryDate, cID, commentText, title FROM btGuestBookEntries, btGuestBook WHERE approved = 1 AND btGuestBook.bID = btGuestBookEntries.bID ORDER BY entryDate DESC $limit";
- $rows = $db->getAll($query);
- return $rows;
- }
- }
- ?>
- ## Error by using empty num [plain_text]
- Uncaught exception 'ADODB_Exception' with message 'mysql error: [1064:
- You have an error in your SQL syntax; check the manual that corresponds
- to your MySQL server version for the right syntax to use near
- 'WHERE bID=48' at line 1] in EXECUTE("UPDATE btLatestGuestbookEntries
- SET title='Testing',num= WHERE bID=48")
Add Comment
Please, Sign In to add comment