dao.init.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. if (!defined('IS_INITPHP')) exit('Access Denied!');
  3. /*********************************************************************************
  4. * InitPHP 3.8.1 国产PHP开发框架 Dao-dao Dao基类
  5. *-------------------------------------------------------------------------------
  6. * 版权所有: CopyRight By initphp.com
  7. * 您可以自由使用该源码,但是在使用过程中,请保留作者信息。尊重他人劳动成果就是尊重自己
  8. *-------------------------------------------------------------------------------
  9. * $Author:zhuli
  10. * $Dtime:2013-5-29
  11. ***********************************************************************************/
  12. class daoInit{
  13. /**
  14. * @var dbInit
  15. */
  16. public $db = NULL;
  17. /**
  18. * @var cacheInit
  19. */
  20. public $cache = NULL;
  21. /**
  22. * @var nosqlInit
  23. */
  24. public $nosql = NULL;
  25. /**
  26. * 运行数据库
  27. * 1. 初始化DB类 DAO中调用方法 $this->dao->db
  28. */
  29. public function run_db() {
  30. if ($this->db == NULL) {
  31. require(INITPHP_PATH . "/core/dao/db/db.init.php");
  32. $this->db = InitPHP::loadclass('dbInit');
  33. $this->db->init_db('');
  34. }
  35. return $this->db;
  36. }
  37. /**
  38. * 运行缓存模型
  39. * 1. 初始化cache类 DAO中调用方法 $this->dao->cache
  40. */
  41. public function run_cache() {
  42. if ($this->cache == NULL) {
  43. require(INITPHP_PATH . "/core/dao/cache/cache.init.php");
  44. $this->cache = InitPHP::loadclass('cacheInit');
  45. $this->cache->db_handle = $this->db; //db对象,MYSQL缓存中需要用到
  46. }
  47. return $this->cache;
  48. }
  49. /**
  50. * 运行nosql
  51. * $this->getNosql()
  52. */
  53. public function run_nosql() {
  54. if ($this->nosql == NULL) {
  55. require(INITPHP_PATH . "/core/dao/nosql/nosql.init.php");
  56. $this->nosql = InitPHP::loadclass('nosqlInit');
  57. }
  58. return $this->nosql;
  59. }
  60. }