tao.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. class biTao extends biModel
  3. {
  4. /**
  5. * Fetch tables.
  6. *
  7. * @access protected
  8. * @return array
  9. */
  10. protected function fetchAllTables()
  11. {
  12. $prefix = $this->config->db->prefix;
  13. $excludes = $this->config->bi->duckdbExcludeTables;
  14. foreach($excludes as $index => $table) $excludes[$index] = $prefix . $table;
  15. return $this->dao->select("table_name as 'table'")
  16. ->from('information_schema.tables')
  17. ->where('table_type')->eq('BASE TABLE')
  18. ->andWhere('table_schema')->eq($this->config->db->name)
  19. ->andWhere('table_name')->notin($excludes)
  20. ->fetchPairs();
  21. }
  22. /**
  23. * Fetch table queue.
  24. *
  25. * @access protected
  26. * @return array
  27. */
  28. protected function fetchTableQueue()
  29. {
  30. $prefix = $this->config->db->prefix;
  31. $excludes = $this->config->bi->duckdbExcludeTables;
  32. foreach($excludes as $index => $table) $excludes[$index] = $prefix . $table;
  33. return $this->dao->select('object')->from(TABLE_DUCKDBQUEUE)
  34. ->where('object')->notin($excludes)
  35. ->andWhere('updatedTime >= syncTime', true)
  36. ->orWhere('syncTime IS NULL')
  37. ->markRight(1)
  38. ->fetchPairs();
  39. }
  40. /**
  41. * Update sync time.
  42. *
  43. * @param array $tables
  44. * @access protected
  45. * @return void
  46. */
  47. protected function updateSyncTime($tables)
  48. {
  49. $this->dao->update(TABLE_DUCKDBQUEUE)
  50. ->set('syncTime')->eq(helper::now())
  51. ->where('object')->in($tables)
  52. ->exec();
  53. }
  54. /**
  55. * Fetch action date.
  56. *
  57. * @access protected
  58. * @return object
  59. */
  60. protected function fetchActionDate()
  61. {
  62. return $this->dao->select('min(date) as minDate, max(date) as maxDate')
  63. ->from(TABLE_ACTION)
  64. ->where('date')->ge('2009-01-01')
  65. ->fetch();
  66. }
  67. }