Source for file BindSimpleTable.php

Documentation is available at BindSimpleTable.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. import('sylar.common.system.ExceptionInSylar');
  25. import('sylar.common.db.mysql.MysqlDriver');
  26. import('sylar.common.data.SimpleTable');
  27.  
  28. /**
  29. * Bind SimpleTable to DBTable
  30. *
  31. *
  32. * @package Sylar
  33. * @version 1.0
  34. * @since 04/mar/08
  35. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  36. * @copyright Sylar Development Team
  37. */
  38. class Sylar_BindSimpleTable extends Sylar_MysqlDriver{
  39. function __construct(Sylar_DataBaseConfiguration $dbConfiguration=null){
  40. parent::__construct($dbConfiguration);
  41. }
  42. function __destruct(){
  43. // nothing to do at the moment
  44. }
  45.  
  46. /**
  47. * Exec Select and fill SimpleTable
  48. * Exec the query on db and fill data results in the SimpleTable Object param.
  49. * Return filled SimpleTable, on error return false
  50. *
  51. * @since 03-2008
  52. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  53. *
  54. * @return boolean
  55. * @param Sylar_SimpleTable &$sTable the SimpleTable object to fill with data extracted from db by $query
  56. * @param string $query sql query to execute on db
  57. * @param boolean $empyResult flag to remove data from resultset of DataBase Quesry. Default is true
  58. */
  59. public function selectToTable(Sylar_SimpleTable &$sTable, $query, $empyResult=true){
  60. try{
  61. $this->execSmartQuery($query);
  62. for($i=0; $i<$this->resultRows(); $i++){
  63. $sTable->addSimpleTableRow(new Sylar_SimpleTableRow($this->fetchArrayByNum()));
  64. }
  65. // reset Result if needed
  66. if($empyResult){
  67. $this->resetResults();
  68. }
  69. return true;
  70. }catch (ExceptionInSylar $ex){
  71.  
  72. // send out the exception
  73. throw $ex;
  74. return false;
  75. }
  76. }
  77. }
  78. ?>

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