Ejemplo n.º 1
0
function s_smarty_tpl($tpl)
{
    if (!is_file($tpl) || !is_readable($tpl)) {
        return s_err_arg('no suce file of ' . $tpl);
    }
    $smarty = s_smarty_object();
    try {
        return $smarty->fetch($tpl);
    } catch (SmartyException $se) {
        return s_log($se->getMessage());
    }
}
Ejemplo n.º 2
0
function s_error_handler(&$no = 0, &$log = false, &$file = false, &$line = 0, &$context = false)
{
    echo "system:{$no}";
    return s_log('ERR:' . $log);
}
Ejemplo n.º 3
0
function _s_db_update($table, &$v1, &$v2)
{
    if (s_bad_string($table) || s_bad_array($v1) || s_bad_array($v2) || s_bad_id($v1['id'], $pid)) {
        //没有指定主键,更新失败
        return s_log("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 (!isset($v1[$key]) || $v1[$key] != $v2[$key]) {
            $values[] = "`{$key}`=" . (is_string($value) ? '"' . s_safe_value($value) . '"' : $value);
        }
    }
    if (empty($values)) {
        //不需要修改
        return false;
    }
    return s_db_exec("update `{$table}` set " . implode(", ", $values) . " where `id`={$pid}");
}