adodb-sqlitepo.inc.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. @version v5.20.17 31-Mar-2020
  4. @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
  5. @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
  6. Released under both BSD license and Lesser GPL library license.
  7. Whenever there is any discrepancy between the two licenses,
  8. the BSD license will take precedence.
  9. Portable version of sqlite driver, to make it more similar to other database drivers.
  10. The main differences are
  11. 1. When selecting (joining) multiple tables, in assoc mode the table
  12. names are included in the assoc keys in the "sqlite" driver.
  13. In "sqlitepo" driver, the table names are stripped from the returned column names.
  14. When this results in a conflict, the first field get preference.
  15. Contributed by Herman Kuiper herman#ozuzo.net
  16. */
  17. if (!defined('ADODB_DIR')) die();
  18. include_once(ADODB_DIR.'/drivers/adodb-sqlite.inc.php');
  19. class ADODB_sqlitepo extends ADODB_sqlite {
  20. var $databaseType = 'sqlitepo';
  21. }
  22. /*--------------------------------------------------------------------------------------
  23. Class Name: Recordset
  24. --------------------------------------------------------------------------------------*/
  25. class ADORecordset_sqlitepo extends ADORecordset_sqlite {
  26. var $databaseType = 'sqlitepo';
  27. function __construct($queryID,$mode=false)
  28. {
  29. parent::__construct($queryID,$mode);
  30. }
  31. // Modified to strip table names from returned fields
  32. function _fetch($ignore_fields=false)
  33. {
  34. $this->fields = array();
  35. $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode);
  36. if(is_array($fields))
  37. foreach($fields as $n => $v)
  38. {
  39. if(($p = strpos($n, ".")) !== false)
  40. $n = substr($n, $p+1);
  41. $this->fields[$n] = $v;
  42. }
  43. return !empty($this->fields);
  44. }
  45. }