当前位置: 首页>>代码示例>>PHP>>正文


PHP Mysql::replace方法代码示例

本文整理汇总了PHP中Mysql::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::replace方法的具体用法?PHP Mysql::replace怎么用?PHP Mysql::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mysql的用法示例。


在下文中一共展示了Mysql::replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Mysql

        die;
    }
    if (isset($key)) {
        $key .= ",`" . $v . "`";
        $value .= ",'" . mysql_real_escape_string($_POST[$v]) . "'";
    } else {
        $key = "`" . $v . "`";
        $value = "'" . mysql_real_escape_string($_POST[$v]) . "'";
    }
}
$mysql = new Mysql();
//连接数据库
$userName = $_POST['userName'];
$result = $mysql->select("*", 'user', '`username`', "'{$userName}'");
if (!$result) {
    $mysql->replace("user", "{$key}", "{$value}");
    $userId = mysql_insert_id();
    $mysql->close();
} else {
    $res = ['ok' => 0, 'error' => 'username existed'];
    echo json_encode($res);
    die;
}
$myMemcache = new MyMemcache();
$expireTime = 7 * 24 * 3600;
$token = md5(uniqid(rand(), TRUE));
$myMemcache->set("u" . $userId, $token, $expireTime);
$myMemcache->set($token, $userId, $expireTime);
$myMemcache->close();
$user = [userId => $userId, token => $token, expireTime => $expireTime];
$res = [ok => 1, data => $user];
开发者ID:shaoshao613,项目名称:footprint,代码行数:31,代码来源:register.php

示例2: array

        $_GET['like'] = $myMemcache->get("like" . $_GET['id']) ? $myMemcache->get("like" . $_GET['id']) + 1 : 1;
        $FootList = array('url', 'title', 'id', 'like');
    } else {
        $_GET['like'] = 1;
        $FootList = array('url', 'title');
    }
    foreach ($FootList as $k => $v) {
        if (isset($key)) {
            $key .= ",`" . $v . "`";
            $value .= ",'" . mysql_real_escape_string($_GET[$v]) . "'";
        } else {
            $key = "`" . $v . "`";
            $value = "'" . mysql_real_escape_string($_GET[$v]) . "'";
        }
    }
    $mysql->replace("foot", "{$key}", "{$value}");
    //插入数据
    unset($value);
    unset($key);
}
$_GET['footId'] = mysql_insert_id();
//echo $_GET['footId'];
$myMemcache->set("like" . $_GET['footId'], $_GET['like']);
if (isset($_GET['url'])) {
    $myMemcache->set($_GET['url'], $_GET['footId']);
}
$_GET['timestamp'] = time();
$footprintId = $myMemcache->get($_GET['userId'] . "foot:" . $_GET['footId']);
$FootPrintList = array('userId', 'footId', 'initiative', 'time', 'timestamp');
foreach ($FootPrintList as $k => $v) {
    if (isset($key)) {
开发者ID:shaoshao613,项目名称:footprint,代码行数:31,代码来源:logger.php

示例3: dirname

//打印出所有的 错误信息
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
include "../Visitor.php";
$userId = getUserId();
$mysql = new Mysql();
//$regular=new Regular(null);
//$regular->host="http://www.google.com/";
//$regular->threshold=100;
//$regulars[]=$regular;
//
//$regular=new Regular(null);
//$regular->host="http://www.jd.com/";
//$regular->threshold=10000;
//$regulars[]=$regular;
//var_dump($_POST['data']);
$regulars = json_decode($_POST['data']);
$myMemcache = new MyMemcache();
foreach ($regulars as $item) {
    $key = $item->threshold . "_" . $item->host;
    if ($myMemcache->get($key)) {
        $id = $myMemcache->get($key);
    } else {
        $mysql->insert("regular", "`host`,`threshold`", "'{$item->host}','{$item->threshold}'");
        $id = mysql_insert_id();
        $myMemcache->set($key, $id);
    }
    $time = time();
    $mysql->replace("user_regular", "`user_id`,`regular_id`,`time`", "'{$userId}','{$id}','{$time}'");
}
$data = json_encode($regulars);
echo $data;
开发者ID:shaoshao613,项目名称:footprint,代码行数:31,代码来源:upload.php


注:本文中的Mysql::replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。