Ejemplo n.º 1
0
 /**
  * 更新给定日当天的访问数量
  * @author bobbing
  * @version 0.1.0
  *  2008-5-16
  * $riqi  格式应如下20080516 
  * date('Ymd',time()-86400)
  * 取前一天的ymd格式
  */
 public static function jilucishu($riqi)
 {
     $file_name = "../log/" . 'processTime' . $riqi . ".log";
     $fp = fopen($file_name, 'r');
     $fwriqi = strtotime($riqi);
     $fwtongji = array();
     while (!feof($fp)) {
         $buffer = fgets($fp, 4096);
         //echo $buffer."<br>";
         $linshi = explode('|', $buffer);
         $userid = trim(str_replace('uid:', '', $linshi[7]));
         if ($userid == '') {
         } else {
             if (array_key_exists($userid, $fwtongji)) {
                 $fwtongji[$userid] = $fwtongji[$userid] + 1;
             } else {
                 $fwtongji[$userid] = 1;
             }
         }
     }
     foreach ($fwtongji as $key => $val) {
         $sql = "select count(id) from tpm_fwcishu where yh_id = '" . $key . "' and fw_riqi = " . $fwriqi;
         if (Watt_Db::getDb()->getOne($sql) <= 0) {
             $sql = "insert into tpm_fwcishu (yh_id,fw_cishu,fw_riqi,yh_zhanghu) values ('" . $key . "','" . $val . "'," . $fwriqi . ",'" . TpmYonghuPeer::getYhZhanghuByYhId($key) . "')";
             Watt_Db::getDb()->execute($sql);
         } else {
             $sql = "update tpm_fwcishu set fw_cishu = '" . $val . "' where yh_id = '" . $key . "' and fw_riqi = " . $fwriqi;
             Watt_Db::getDb()->execute($sql);
         }
     }
     fclose($fp);
 }
Ejemplo n.º 2
0
 private function __construct($managerName = null)
 {
     $this->_managerName = $managerName;
     $this->_db = Watt_Db::getDb();
     // 原为getDbx() 导致 Watt_db->_connection 访问出错,因此更改为getDb()
 }
Ejemplo n.º 3
0
 /**
  * 设置锁的过期时间
  * @param  int $time
  * return int
  */
 public function setExpireTime($time)
 {
     $sql = "UPDATE tpm_lock" . " SET life_time=" . $time . " WHERE lock_name='" . chks($this->lock_name) . "'";
     return Watt_Db::getDb()->execute($sql);
 }
Ejemplo n.º 4
0
 /**
  * 说明
  *
  */
 function GetAll($sql)
 {
     $jgsz = Watt_Db::getDb()->getAll($sql);
     //$jgsz  = $this->db->GetAll($sql);
     /*$qusql = mysql_query($sql);
     		if (!$qusql)
     		{
     		$this	->	error	.=	'无法连接数据库<hr>';
     		return   false;
     		}
     		else
     		{
     		while($jigu = @mysql_fetch_assoc($qusql))
     		{
     		$jgsz[] = $jigu;
     		}
     		}*/
     return $jgsz;
 }
Ejemplo n.º 5
0
 private function _getCountWithSql()
 {
     return Watt_Db::getDb()->getOne($this->_getCountSql());
 }
Ejemplo n.º 6
0
 /**
  * 获取数据库所有表的记录数
  *
  * @return unknown
  */
 public static function getDbAllTableCount()
 {
     $re = array();
     $sql = "show tables";
     $dd = Watt_Db::getDb()->getAll($sql);
     if (is_array($dd) && count($dd)) {
         foreach ($dd as $k => $v) {
             $v_ = array_values($v);
             try {
                 Watt_Db::getDb()->getAll("SHOW CREATE VIEW " . $v_[0]);
             } catch (Exception $e) {
                 $sql = "select count(*) as count from " . $v_[0];
                 $dingdan_count = Watt_Db::getDb()->GetOne($sql);
                 $re[$v_[0]] = $dingdan_count;
             }
         }
     }
     return $re;
 }
Ejemplo n.º 7
0
 /**
  * 结束使用只读数据库
  *
  * @author bobit
  * Mon Sep 24 16:37:49 CST 200716:37:49
  */
 public static function endUseReadonlyDb()
 {
     self::$_need_use_readonly_db = 0;
     Watt_Debug::addInfoToDefault('', 'Unset use READONLY DB server');
 }
Ejemplo n.º 8
0
 /**
  * 通过角色 Id 获得用户菜单
  * 这个应该放到 角色的属性里
  *
  * @param int $roleId
  * @return array|null
  */
 public static function getRoleMenus($roleId)
 {
     $sql = "select menu_id,menu_parent_id,menu_name,menu_path,privilege_do \n                from tpm_menu\n                left join tpm_privilege using (privilege_id) \n                left join tpm_role_privilege_rel using (privilege_id) \n                where role_id = {$roleId} \n                   or tpm_menu.privilege_id = 0\n                order by menu_path";
     //		$sql = "select * from tpm_test";
     $arr_menu = Watt_Db::getDb()->getAll($sql);
     //		var_dump( $arr_menu );
     return $arr_menu;
 }