예제 #1
0
<?php

/**
 * 修改专业热度
 * User: ren
 * Date: 15-10-23
 * Time: 下午5:11
 */
header('content-type:text/html;charset=utf-8');
use Phalcon\Db\Adapter\Pdo\Mysql;
$db = new Mysql(['host' => 'localhost', 'username' => 'root', 'password' => 'root', 'dbname' => 'yxk_51']);
$db->execute('set names utf8');
//获取所有省份
$sql = 'select name from site_province';
$provinces = $db->fetchAll($sql);
//获取所有专业id
$sql = 'select maj_id from major';
$majors = $db->fetchAll($sql);
//修改专业数据
$db->begin();
foreach ($majors as $val) {
    //格式省份数据
    $tmp = array_map(function ($argc) {
        $argc['value'] = mt_rand(0, 100);
        return preg_replace('/[省市]/u', '', $argc);
    }, array_slice($provinces, 0, 31));
    $tmp = serialize($tmp);
    $sql = "update major set maj_area='{$tmp}' where maj_id='{$val['maj_id']}'";
    $db->execute($sql);
}
$db->commit();
예제 #2
0
<?php

/**
 * Created by PhpStorm.
 * User: ren
 * Date: 15-11-4
 * Time: 下午4:44
 */
use Phalcon\Db\Adapter\Pdo\Sqlite;
use Phalcon\Db\Adapter\Pdo\Mysql;
header('content-type:text/html;charset=utf-8');
$mysql = new Mysql(['host' => 'localhost', 'username' => 'root', 'password' => 'root', 'dbname' => 'yxk_51']);
$mysql->execute('set names utf8');
//大学大专高职数据
$mysql->execute("update college set city_code=340100 where city_code=341400");
//巢湖并入合肥,县级
$mysql->execute("update school set city_code=340100 where city_code=341400");
//巢湖并入合肥,县级
$mysql->execute("update college set city_code=654000 where city_code=654200");
//塔城地区归伊犁哈萨克自治州统辖
$mysql->execute("update school set city_code=654000 where city_code=654200");
//塔城地区归伊犁哈萨克自治州统辖
$mysql->execute("update college set city_code=654000 where city_code=654300");
//阿勒泰地区归伊犁哈萨克自治州统辖
$mysql->execute("update school set city_code=654000 where city_code=654300");
//阿勒泰地区归伊犁哈萨克自治州统辖
$mysql->execute("update school set city_code=520600 where city_code=522200");
//铜仁地区撤销,改为铜仁市
$mysql->execute("update school set city_code=520500 where city_code=522400");
//毕节地区撤销,改为毕节市
$mysql->execute("update school set city_code=630200 where city_code=632100");
예제 #3
0
 /**
  * DATABASE
  */
 $di['db'] = function () use($config, $di) {
     $logger = $di['logger'];
     $eventsManager = new PhEventsManager();
     // Listen all the database events
     $eventsManager->attach('db', function ($event, $connection) use($logger) {
         if ($event->getType() == 'beforeQuery') {
             $logger->log($connection->getSQLStatement(), PhLogger::INFO);
         }
     });
     $params = ["host" => $config->app_db->host, "username" => $config->app_db->username, "password" => $config->app_db->password, "dbname" => $config->app_db->name, "charset" => 'utf8'];
     $conn = new PhMysql($params);
     // Set everything to UTF8
     $conn->execute('SET NAMES UTF8', []);
     $conn->setEventsManager($eventsManager);
     return $conn;
 };
 /**
  * If the configuration specify the use of metadata adapter use it
  * or use memory otherwise
  */
 $di['modelsMetadata'] = function () use($config) {
     $metaData = new PhMetadataFiles(['metaDataDir' => ROOT_PATH . $config->app_model->metadata]);
     //Set a custom meta-data database introspection
     $metaData->setStrategy(new FlyAnnotationsMetaDataInitializer());
     return $metaData;
 };
 $di['modelsManager'] = function () {
     $eventsManager = new PhEventsManager();
예제 #4
0
 /**
  * Executes the SQL statement without caching
  *
  * @param string $sqlStatement
  * @param array $bindParams
  * @param array $bindTypes
  * @return boolean
  */
 public function execute($sqlStatement, $bindParams = null, $bindTypes = null)
 {
     $this->_connect();
     return parent::execute($sqlStatement, $bindParams, $bindTypes);
 }
예제 #5
0
    //公办,基本点击率+1
    if ($val['public_type'] == 1) {
        $basic += 1;
    }
    //有logo图片,基本点击率+1
    if ($val['col_logo']) {
        $basic += 1;
    }
    //有缩略图,基本点击率+1
    if ($val['col_thumb']) {
        $basic += 1;
    }
    //有排名,基本点击率+1
    if ($val['col_rank'] > 0) {
        $basic += 1;
        if ($val['col_rank'] < 20) {
            $basic += 5;
        } elseif ($val['col_rank'] < 50) {
            $basic += 2;
        } elseif ($val['col_rank'] < 100) {
            $basic += 1;
        }
    }
    $click = $basic * mt_rand(80, 100);
    $hot = $click * mt_rand(5, 9) + mt_rand(0, 10);
    //修改热度
    $sql = "update college set col_click={$click},col_hot={$hot} where col_id={$val['col_id']}";
    $db->execute($sql);
    $basic = 1;
}
$db->commit();
예제 #6
0
 /**
  * Calling the parent execute method in PDO class
  *
  * @param String $sqlStatement
  * @param array  $bindParams
  * @param array  $bindTypes
  *
  * @return boolean
  */
 protected function callParentExecute($sqlStatement, $bindParams, $bindTypes)
 {
     return parent::execute($sqlStatement, $bindParams, $bindTypes);
 }