本文整理汇总了PHP中Table::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::insert方法的具体用法?PHP Table::insert怎么用?PHP Table::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPersist
public function testPersist()
{
$jsonFilename = __DIR__ . '/workdir/persisting.json';
file_put_contents($jsonFilename, '[]');
$table = new Table($jsonFilename);
$table->insert(['foo' => 'bar', 'baz' => 'bat']);
$table->insert(['ab' => 'cd', 'ef' => 'gh']);
$table->persist();
$tableLoaded = new Table($jsonFilename);
$this->assertSame(2, $tableLoaded->count());
unlink($jsonFilename);
}
示例2: OnlineIt
public static function OnlineIt($order_id, $pay_id, $money, $currency = 'CNY', $service = 'alipay', $bank = '支付宝')
{
list($_, $_, $quantity, $_) = explode('-', $pay_id);
if (!$order_id || !$pay_id || $money <= 0) {
return false;
}
$order = Table::Fetch('order', $order_id);
if ($order['state'] == 'unpay') {
Table::UpdateCache('order', $order_id, array('pay_id' => $pay_id, 'money' => $money, 'state' => 'pay', 'service' => $service, 'quantity' => $quantity, 'pay_time' => time()));
$order = Table::FetchForce('order', $order_id);
if ($order['state'] == 'pay') {
$table = new Table('pay');
$table->id = $pay_id;
$table->order_id = $order_id;
$table->money = $money;
$table->currency = $currency;
$table->bank = $bank;
$table->service = $service;
$table->create_time = time();
$table->insert(array('id', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank'));
//TeamBuy Operation
ZTeam::BuyOne($order);
}
}
return true;
}
示例3: Create
public static function Create($email, $city_id)
{
if (!Utility::ValidEmail($email, true)) {
return;
}
$secret = md5($email . $city_id);
$table = new Table('subscribe', array('email' => $email, 'city_id' => $city_id, 'secret' => $secret));
Table::Delete('subscribe', $email, 'email');
$table->insert(array('email', 'city_id', 'secret'));
}
示例4: Create
public static function Create($mobile, $city_id, $secret = null, $enable = false)
{
if (!Utility::IsMobile($mobile, true)) {
return;
}
$secret = $secret ? $secret : Utility::VerifyCode();
$have = Table::Fetch('smssubscribe', $mobile, 'mobile');
if ($have && $have['city_id'] == $city_id && 'Y' == $have['enable']) {
return true;
}
$table = new Table('smssubscribe', array('mobile' => $mobile, 'enable' => $enable ? 'Y' : 'N', 'city_id' => $city_id, 'secret' => $secret));
Table::Delete('smssubscribe', $mobile, 'mobile');
return $table->insert(array('mobile', 'city_id', 'secret', 'enable'));
}
示例5: Create
public static function Create($email, $city_id)
{
if (!Utility::ValidEmail($email, true)) {
return;
}
$secret = md5($email . $city_id);
$table = new Table('subscribe', array('email' => $email, 'city_id' => $city_id, 'secret' => $secret));
Table::Delete('subscribe', $email, 'email');
$table->insert(array('email', 'city_id', 'secret'));
/* notice */
/*
$host = $_SERVER['HTTP_HOST'];
$u = "http://notice.zuitu.com/subscribe.php?email={$email}&city_id={$city_id}&secret={$secret}&host={$host}";
Utility::HttpRequest($u);
*/
}
示例6: _doInsert
/**
* @return mixed The primary key value(s), as an associative array if the
* key is compound, or a scalar if the key is single-column.
*/
protected function _doInsert()
{
/**
* Execute the INSERT (this may throw an exception)
*/
$data = array_intersect_key($this->getArrayCopy(), $this->_cleanData);
$primaryKey = $this->_table->insert($data);
/**
* Save the new primary key value in _data. The primary key may have
* been generated by a sequence or auto-increment mechanism, and this
* merge should be done before the _postInsert() method is run, so the
* new values are available for logging, etc.
*/
$this->setFromArray($primaryKey);
return $primaryKey;
}
示例7: OnlineIt
public static function OnlineIt($order_id, $pay_id, $money, $currency = 'CNY', $service = 'alipay', $bank = '支付宝', $trade_no = '')
{
list($_, $_, $quantity, $_) = explode('-', $pay_id);
if (!$order_id || !$pay_id || $money <= 0) {
return false;
}
$order = Table::Fetch('order', $order_id);
$team = Table::Fetch('team', $order['team_id']);
$user_id = abs(intval($order['user_id']));
team_state($team);
if ($order['state'] == 'unpay') {
$table = new Table('pay');
$table->id = $pay_id;
$table->vid = $trade_no;
$table->order_id = $order_id;
$table->money = $money;
$table->currency = $currency;
$table->bank = $bank;
$table->service = $service;
$table->create_time = time();
$ia = array('id', 'vid', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank');
if (Table::Fetch('pay', $pay_id) || !$table->insert($ia)) {
return false;
}
//update user money; +money
Table::UpdateCache('user', $user_id, array('money' => array("money + {$money}")));
$u = array('user_id' => $user_id, 'admin_id' => 0, 'money' => $money, 'direction' => 'income', 'action' => 'paycharge', 'detail_id' => $pay_id, 'create_time' => time());
DB::Insert('flow', $u);
$user = Table::FetchForce('user', $user_id);
//print_r($user);exit;
if ($user['money'] < $order['origin']) {
return false;
}
if (in_array($team['state'], array('soldout')) || $team['end_time'] < time()) {
return false;
}
Table::UpdateCache('order', $order_id, array('pay_id' => $pay_id, 'money' => $money, 'state' => 'pay', 'trade_no' => $trade_no, 'service' => $service, 'quantity' => $quantity, 'pay_time' => time()));
$order = Table::FetchForce('order', $order_id);
if ($order['state'] == 'pay') {
//TeamBuy Operation
ZTeam::BuyOne($order);
}
}
return true;
}
示例8: Table
/**
* 用户信息转移
* @author tianyunchong
* @datetime 2016/05/26
*/
ini_set('magic_quotes_gpc', "1");
include_once "../common.php";
$conn = new Table("forbuyers-test");
$connLocal = new Table("local198");
$supid = 0;
while (1) {
$userArr = $conn->findAll("select * from fbsupplier.fb_sup_user where supid > '" . $supid . "' limit 100");
if (empty($userArr)) {
break;
}
foreach ($userArr as $value) {
$supid = $value["supid"];
$existArr = $connLocal->findOne("select * from fbsupplier.fb_sup_user where supid = '" . $supid . "' limit 1");
if ($existArr) {
continue;
}
/** 邮箱不能重复 */
$existArr = $connLocal->findOne("select * from fbsupplier.fb_sup_user where email = '" . $value["email"] . "' limit 1");
if ($existArr) {
continue;
}
$value["notice"] = intval($value["notice"]);
$connLocal->insert($value, "fbsupplier.fb_sup_user");
echo $supid . "\t" . $value["username"] . "\n";
}
}
示例9: template
<?php
require_once dirname(dirname(__FILE__)) . '/app.php';
need_login();
need_auth(abs(intval($INI['system']['forum'])) > 0);
$publics = option_category('public');
if ($_POST) {
$topic = new Table('topic', $_POST);
if ($topic->category == 'city') {
$topic->city_id = $city['id'];
} else {
$topic->public_id = $topic->category;
}
$topic->user_id = $topic->last_user_id = $login_user_id;
$topic->create_time = $topic->last_time = time();
$topic->reply_number = 0;
$insert = array('user_id', 'city_id', 'public_id', 'content', 'last_user_id', 'last_time', 'reply_number', 'create_time', 'title');
if ($topic_id = $topic->insert($insert)) {
Utility::Redirect(WEB_ROOT . "/forum/topic.php?id={$topic_id}");
}
$topic = $_POST;
}
$id = abs(intval($_GET['id']));
include template('forum_new');
示例10: PostNewComments
public static function PostNewComments($details)
{
$added_date = date('Y-m-d :H:m:s');
$user_id = $details['user_id'];
$team_id = $details['team_id'];
$comments = $details['comments'];
$table = new Table('comments', array('user_id' => $user_id, 'team_id' => $team_id, 'comments' => $comments, 'added_date' => $added_date, 'status' => 'active'));
$table->insert(array('user_id', 'team_id', 'comments', 'added_date', 'status'));
}
示例11: array
$header = array();
$header[] = "serveToken:" . microtime(1);
$header[] = "apiKey:1kg8tunzfxt8zvzpf53vjr5es45lvszh";
$str = curlPost($api, $header, $postData);
if (!isset($str["accessToken"])) {
exit("用户登录验证失败!\n");
} else {
echo "用户登录验证成功!\n";
}
/*查询下所有的推广计划 */
$api = "https://api.e.360.cn/2.0/account/getCampaignIdList";
$header[] = "accessToken:" . $str["accessToken"];
$header[] = "sessionToken:" . $str["sessionToken"];
$params = array("format" => "json");
$str = curlPost($api, $header, $params);
if (!isset($str["campaignIdList"])) {
exit("无法获取到任何推广计划id\n");
} else {
echo "所有推广计划获取成功!\n";
}
$campaignIdList = $str["campaignIdList"];
/* 根据推广信息id查询推广计划的具体内容*/
$campaignArr = array();
$api = "https://api.e.360.cn/2.0/campaign/getInfoByIdList";
$params = array("format" => "json", "idList" => json_encode($campaignIdList));
$str = curlPost($api, $header, $params);
foreach ($str["campaignList"] as $value) {
$conn->insert(array("id" => $value["id"], "title" => $value["name"]), "tianyunzi.360_jihua");
echo "计划[" . $value["name"] . "]插入\n";
continue;
}
示例12: actionCreate
public function actionCreate()
{
$this->layout = false;
$table = new Table();
$column = new Column();
if (isset($_POST['Table'], $_POST['Column'])) {
$table->attributes = $_POST['Table'];
$column->attributes = $_POST['Column'];
/*
* Add index
*/
$addIndices = array();
if (isset($_POST['createIndexPrimary'])) {
$column->createPrimaryKey = true;
}
if (isset($_POST['createIndex'])) {
$addIndices['INDEX'] = $column->COLUMN_NAME;
}
if (isset($_POST['createIndexUnique'])) {
$column->createUniqueKey = true;
}
if (isset($_POST['createIndexFulltext'])) {
$addIndices['FULLTEXT'] = $column->COLUMN_NAME . (array_search($column->COLUMN_NAME, $addIndices) !== false ? '_fulltext' : '');
}
$table->columns = array($column);
if ($sql = $table->insert()) {
$response = new AjaxResponse();
$response->addNotification('success', Yii::t('core', 'successAddTable', array('{table}' => $table->TABLE_NAME)), null, $sql);
$response->redirectUrl = '#tables/' . $table->TABLE_NAME . '/structure';
$response->executeJavaScript('sideBar.loadTables(schema);');
foreach ($addIndices as $type => $indexName) {
try {
$index = new Index();
$index->throwExceptions = true;
$index->TABLE_NAME = $table->TABLE_NAME;
$index->TABLE_SCHEMA = $this->schema;
$index->INDEX_NAME = $indexName;
$index->setType($type);
$indexCol = new IndexColumn();
$indexCol->COLUMN_NAME = $column->COLUMN_NAME;
$index->columns = array($indexCol);
$sql = $index->save();
$response->addNotification('success', Yii::t('core', 'successCreateIndex', array('{index}' => $index->INDEX_NAME)), null, $sql);
$response->refresh = true;
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorCreateIndex', array('{index}' => $index->INDEX_NAME)), $ex->getText(), $ex->getSql());
}
}
$this->sendJSON($response);
}
}
$collations = Collation::model()->findAll(array('order' => 'COLLATION_NAME', 'select' => 'COLLATION_NAME, CHARACTER_SET_NAME AS collationGroup'));
CHtml::generateRandomIdPrefix();
$data = array('table' => $table, 'column' => $column, 'collations' => $collations, 'storageEngines' => StorageEngine::getSupportedEngines());
$data['columnForm'] = $this->renderPartial('/column/formBody', $data, true);
$this->render('form', $data);
}
示例13: dirname
<?php
require_once dirname(dirname(dirname(__FILE__))) . '/app.php';
need_manager();
need_auth('admin');
$id = abs(intval($_REQUEST['id']));
$category = Table::Fetch('category', $id);
$table = new Table('category', $_POST);
$table->letter = strtoupper($table->letter);
$uarray = array('zone', 'ename', 'letter', 'name', 'czone', 'sort_order');
if (!$_POST['name'] || !$_POST['ename'] || !$_POST['letter']) {
Session::Set('error', '中文名称、英文名称、首字母均不能为空');
Utility::Redirect(null);
}
if ($category) {
if ($flag = $table->update($uarray)) {
Session::Set('notice', '编辑分类成功');
} else {
Session::Set('error', '编辑分类失败');
}
option_category($category['zone'], true);
} else {
if ($flag = $table->insert($uarray)) {
Session::Set('notice', '新建分类成功');
} else {
Session::Set('error', '新建分类失败');
}
}
option_category($table->zone, true);
Utility::Redirect(null);
示例14: template
<?php
require_once dirname(dirname(dirname(__FILE__))) . '/app.php';
need_manager(true);
$pages = array('help_tour' => '玩转' . $INI['system']['abbreviation'], 'help_faqs' => '常见问题', 'help_zuitu' => '什么是' . $INI['system']['abbreviation'], 'help_api' => '开发API', 'about_contact' => '联系方式', 'about_us' => '关于' . $INI['system']['abbreviation'], 'about_job' => '工作机会', 'about_terms' => '用户协议', 'about_privacy' => '隐私声明');
$id = strval($_GET['id']);
if ($id && !in_array($id, array_keys($pages))) {
Utility::Redirect(WEB_ROOT . "/manage/system/page.php");
}
$n = Table::Fetch('page', $id);
if ($_POST) {
$table = new Table('page', $_POST);
$table->SetStrip('value');
if ($n) {
$table->SetPk('id', $id);
$table->update(array('id', 'value'));
} else {
$table->insert(array('id', 'value'));
}
Session::Set('notice', "页面:{$pages[$id]}编辑成功");
Utility::Redirect(WEB_ROOT . "/manage/system/page.php?id={$id}");
}
$value = $n['value'];
include template('manage_system_page');
示例15: elseif
exit;
} elseif ($action == 'add') {
$question['type'] = 'radio';
$question['is_show'] = 1;
$question['order'] = 0;
include template('manage_vote_question_edit');
exit;
//添加问题,数据处理
} elseif ($action == 'add_submit') {
$question['title'] = isset($_POST['question']['title']) ? addslashes(htmlspecialchars($_POST['question']['title'])) : '';
$question['type'] = isset($_POST['question']['type']) && $_POST['question']['type'] == 'radio' ? 'radio' : 'checkbox';
$question['is_show'] = isset($_POST['question']['is_show']) && $_POST['question']['is_show'] ? 1 : 0;
$question['order'] = isset($_POST['question']['order']) && is_numeric($_POST['question']['order']) ? $_POST['question']['order'] : '0';
$table = new Table('vote_question', $question);
$title_check = Table::Count('vote_question', array("title = '{$question['title']}'"));
if ($title_check) {
Session::Set('error', '“' . $question['title'] . '”已存在,请换一个标题。');
Utility::Redirect(WEB_ROOT . '/manage/vote/question.php?action=add');
exit;
}
$table->addtime = time();
$table->insert(array('title', 'type', 'is_show', 'addtime', 'order'));
Session::Set('notice', '添加调查问题成功');
Utility::Redirect(WEB_ROOT . '/manage/vote/question.php?action=list-all');
exit;
}
if ($action == 'add' || $action == 'edit') {
include template('manage_vote_question_edit');
} else {
include template('manage_vote_question_list');
}