Source for file 05.php

Documentation is available at 05.php

  1. <?php
  2. /*
  3. * This file is part of Sylar.
  4. *
  5. * Sylar is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Sylar is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with Sylar. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * @copyright Copyright Sylar Development Team
  19. * @license http://www.gnu.org/licenses/ GNU Public License V2.0
  20. * @see https://launchpad.net/sylar/
  21. * @see http://www.giano-solutions.com
  22. */
  23.  
  24. /**
  25. * Example Sylar File
  26. * Some files that shows how sylar works
  27. *
  28. * @package Sylar
  29. * @version 1.0
  30. * @since 02-2008
  31. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  32. * @copyright Sylar Development Team
  33. */
  34.  
  35. #
  36. # Include the bas Application settings
  37. #
  38.  
  39. require_once 'config/appConfig.php';
  40. ?>
  41.  
  42. <html>
  43. <head>
  44.  
  45. </head>
  46.  
  47. <body>
  48. <p>Db bind SimpleTable</p>
  49. <a href='06.php'>SimpleTable in htmls from DB &raquo;</a><br><br>
  50. <textarea style='width: 100%; height: 500px;'>
  51. <?php
  52.  
  53. // Sylar Import
  54. import('sylar.common.system.SylarUtils');
  55. import('sylar.common.data.SimpleTable');
  56. import('sylar.common.db.mysql.data.BindSimpleTable');
  57.  
  58. // Application Import
  59. import("~.giano.common.db.mysql.SqlBuilderLogUtils");
  60. import('app.giano.presentation.FormatLogList');
  61.  
  62.  
  63. try{
  64. echo "Binding data from DB in table SYLAR_event_log, 30 random rows";
  65.  
  66. // Create SimpleTable Object
  67. $simpleTb = new Sylar_SimpleTable("Log Info");
  68. // Create table Header Container
  69. $simpleTbHd = new Sylar_SimpleTableHeader(3);
  70. // Adding Column header descriptions
  71. $col = new Sylar_SimpleTableHeaderColumn("event_id");
  72. $col->setColumnName("EVENT ID");
  73. $col->setColumnType("int");
  74. $col->setColumnDesc("the unique id of the event");
  75. $simpleTbHd->addColumn($col);
  76. $simpleTbHd->addColumn(new Sylar_SimpleTableHeaderColumn("level"));
  77. $simpleTbHd->addColumn(new Sylar_SimpleTableHeaderColumn("event_desc"));
  78. /*
  79. 'columnCode' => 'level',
  80. 'columnType' => 'string',
  81. 'columnName' => 'Level',
  82. 'columnDesc' => 'Event level'
  83.  
  84. 'columnCode' => 'event_desc',
  85. 'columnType' => 'string',
  86. 'columnName' => 'Description',
  87. 'columnDesc' => 'Desc for log'
  88. */
  89. // insert header in table
  90. $simpleTb->setColumnsHeader($simpleTbHd);
  91.  
  92. // Prepare binding object
  93. $bindTb = new Sylar_BindSimpleTable();
  94. // Initialize Formatter object
  95. $formatLog = new FormatLogList();
  96. // Create Sql builder object
  97. $sqlBuilder = new SqlBuilderLogUtils();
  98.  
  99. // get the Sql Query to run
  100. $sql = $sqlBuilder->extractLastEvents(30);
  101. // Exec query and bind data in the SimpleTable
  102. $bindTb->selectToTable($simpleTb, $sql);
  103. echo "\n\nRighe: ".$simpleTb->getRows();
  104. // At the end format table in TXT Mode with first formatter example method
  105. if($simpleTb->getRows() > 0){
  106. echo"\nHere it is:\n".$formatLog->makeLogList( $simpleTb );
  107. }
  108.  
  109. }catch (ExceptionInSylar $ex){
  110. echo "\n".$ex->getMessage();
  111. }
  112. echo "\n\n\n-----------------------";
  113. echo "\nSylar included Files:\n";
  114. Sylar_SylarUtils::showIncludedFiles();
  115. echo "\n\nSylar Defined Costants:\n";
  116. Sylar_SylarUtils::showDefinedCostant();
  117. ?>
  118. </textarea>
  119. </body>
  120. </html>

Documentation generated on Thu, 24 Apr 2008 16:14:12 +0200 by phpDocumentor 1.3.0RC3