Example #1
0
 /**
  * 计数器-x(默认为1)
  *
  * @param array  $key    键配置
  * @param number $offset 计数器减的数
  *
  * @return \int
  */
 public static function decrement(array $key, $offset = 1)
 {
     $table = self::db()->showTable();
     $field_value = static::$_fiels_value;
     $sql_params = $key;
     $sql_params['offset'] = $offset;
     $sql = "UPDATE {$table} SET {$field_value} = {$field_value} - :offset WHERE ";
     $where = array();
     foreach (static::$_field_keys as $field) {
         $where[] = "{$field} = :{$field}";
     }
     $sql .= implode(' AND ', $where);
     $mysql = new \Comm\Db\Mysql();
     return $mysql->exec($sql, $sql_params);
 }
Example #2
0
 /**
  * 解锁复制模板资源内容
  * 
  * @param int    $to_tpl_id   目标模板ID
  * @param string $uid         当前登录用户
  * 
  * @return int
  */
 public static function unlock($to_tpl_id, $uid = false)
 {
     $to_tpl_id = (int) $to_tpl_id;
     $theme = self::validateAuth($to_tpl_id, $uid);
     $table = self::db()->showTable();
     $mysql = new \Comm\Db\Mysql();
     $sql = "INSERT IGNORE INTO {$table} (tpl_id, resource_name, content) SELECT {$to_tpl_id}, resource_name, content FROM {$table} WHERE tpl_id = ?";
     return $mysql->executeSql($sql, [$theme['alias_id']]);
 }