Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. ## db.xml [html]
  2. <?xml version="1.0"?>
  3. <schema version="0.3">
  4. <table name="btLatestGuestbookEntries">
  5. <field name="bID" type="I">
  6. <key />
  7. <unsigned />
  8. </field>
  9. <field name="title" type="X2">
  10. </field>
  11. <field name="num" type="I">
  12. <unsigned />
  13. </field>
  14. </table>
  15. </schema>
  16.  
  17. ## add.php [php]
  18. <?php echo $form->label('title', t('Title'));?>
  19. <?php echo $form->text('title', array('style' => 'width: 320px'));?>
  20.  
  21. <?php echo $form->label('num', t('Number of entries'));?>
  22. <?php echo $form->text('num', array('style' => 'width: 3em'));?>
  23.  
  24. ## controller.php [php]
  25. <?php
  26. class LatestGuestbookEntriesBlockController extends BlockController {
  27.  
  28. var $pobj;
  29.  
  30. protected $btDescription = "Shows the latest guestbook entries.";
  31. protected $btName = "Latest Guestbook Entries";
  32. protected $btTable = 'btLatestGuestbookEntries';
  33. protected $btInterfaceWidth = "350";
  34. protected $btInterfaceHeight = "300";
  35.  
  36. function getTitle() {
  37. return $this->title;
  38. }
  39.  
  40. function getEntries($num = 3) {
  41. $db = Loader::db();
  42.  
  43. if($this->num) {
  44. $limit = " LIMIT {$this->num}";
  45. }
  46.  
  47. $query = "SELECT entryDate, cID, commentText, title FROM btGuestBookEntries, btGuestBook WHERE approved = 1 AND btGuestBook.bID = btGuestBookEntries.bID ORDER BY entryDate DESC $limit";
  48. $rows = $db->getAll($query);
  49.  
  50. return $rows;
  51. }
  52. }
  53. ?>
  54.  
  55. ## Error by using empty num [plain_text]
  56. Uncaught exception 'ADODB_Exception' with message 'mysql error: [1064:
  57. You have an error in your SQL syntax; check the manual that corresponds
  58. to your MySQL server version for the right syntax to use near
  59. 'WHERE bID=48' at line 1] in EXECUTE("UPDATE btLatestGuestbookEntries
  60. SET title='Testing',num= WHERE bID=48")
Add Comment
Please, Sign In to add comment