码迷,mamicode.com
首页 > Web开发 > 详细

php function集合

时间:2016-09-20 11:50:53      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

/*更新商品的某个字段*/
function update_goods($goods_id, $field, $value)
{
    if ($goods_id)
    {
        /* 清除缓存 */
        clear_cache_files();

        $sql = "UPDATE " . $GLOBALS[ecs]->table(goods) .
                " SET $field = ‘$value‘ , last_update = ‘". gmtime() ."" .
                "WHERE goods_id " . db_create_in($goods_id);
        return $GLOBALS[db]->query($sql);
    }
    else
    {
        return false;
    }
}
function message($msg, $url = NULL, $type = succeed, $waitSecond = 2) {
        if ($url == NULL)
            $url = javascript:history.back();;
        if ($type == error) {
            $title = 错误信息;
        } else {
            $title = 提示信息;
        }
        $data [title] = $title;
        $data [message] = $msg;
        $data [type] = $type;
        $data [url] = $url;
        $data [second] = $waitSecond;
        $this->assign(data, $data);
        $this->display(message);
        exit();
    }

    // 弹出信息
function alert($msg, $url = NULL, $parent = false) {
        header("Content-type: text/html; charset=utf-8");
        $alert_msg = "alert(‘$msg‘);";
        if (empty($url)) {
            $gourl = history.go(-1);;
        } else {
            $gourl = ($parent ? parent : window) . ".location.href = ‘{$url}‘";
        }
        echo "<script>$alert_msg $gourl</script>";
        exit();
    }

 

php function集合

标签:

原文地址:http://www.cnblogs.com/wesky/p/5887961.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!