コード例 #1
0
ファイル: devinc.mdb2.php プロジェクト: anjestar/SHFramework
function _s_db_update($table, &$v1, &$v2)
{
    if (is_int($v1)) {
        $v1 = s_db($table, $v1);
    }
    if (s_bad_string($table) || s_bad_array($v1) || s_bad_array($v2) || s_bad_id($v1["id"], $pid)) {
        return s_err_arg("no primary key.");
    }
    if (defined("APP_DB_PREFIX")) {
        //替换表名:"%s_user:update" => "201204disney_user:update"
        $table = sprintf($table, APP_DB_PREFIX, true);
    }
    if (isset($v2["id"])) {
        //防止更新主键
        unset($v2["id"]);
    }
    // 防止有重复的值
    //$v2 = array_unique($v2);
    // 对$v1和$v2数据归类
    $values = array();
    foreach ($v2 as $key => $value) {
        if ($v1[$key] != $v2[$key]) {
            $values[] = "`{$key}`=" . (is_string($value) ? '"' . s_safe_value($value) . '"' : $value);
        }
    }
    if (empty($values)) {
        return true;
    }
    $sql = "update `{$table}` set " . implode(", ", $values) . " where `id`={$pid}";
    return s_db_exec($sql);
}
コード例 #2
0
ファイル: general.php プロジェクト: anjestar/SHFramework
    $params['name'] = $name;
    $params['start'] = $start;
    $params['stop'] = $stop;
    $params['odds'] = $odds;
    $params['items'] = $items;
    $params['nums'] = $nums;
    $params['confirm'] = 1;
    $params['avg'] = $avg;
    //未确认
    return s_action_json($params);
}
//将配置信息存储起来
$data = array('name' => $name, 'key' => $akey, 'start' => $start, 'stop' => $stop, 'odds' => $odds, 'uid' => $user['id'], 'uname' => $user['screen_name'], 'sum' => $sum, 'fdate' => date('Y-m-d'), 'ftime' => date('Y-m-d H:i:s'));
//$sql = sprintf("insert into `%s_bingo_config (`name`, `key`, `start`, `stop`, `odds`, `uid`, `uname`, `sum`, `fdate`, `ftime`) values('%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s')`;",
//FRAMEWORK_DBPREFIX, $name, $akey, $start, $stop, $odds, $user['id'], $user['screen_name'], $sum, date('Y-m-d'), date('Y-m-d H:i:s'));
$cid = s_db(sprintf("%s_bingo_config:insert", FRAMEWORK_DBPREFIX), $data);
//产生sum个优惠码
$codes = array();
foreach ($names as $key => $data) {
    $max = $data["count"];
    $arr = array_fill(0, $max, $key);
    $codes = array_merge($arr, $codes);
}
//打乱顺序,再分配中奖时间
shuffle($codes);
shuffle($codes);
shuffle($codes);
shuffle($codes);
//从活动开始按每天给中奖代码分配中奖时间
//中奖代码下标
$time = $time1;