本文整理汇总了PHP中Database::Insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::Insert方法的具体用法?PHP Database::Insert怎么用?PHP Database::Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddServer
public static function AddServer($DisplayName, $IP, $Port)
{
// Make it in the database
Database::Insert(self::$TableName, array("Name" => $DisplayName, "IP" => $IP, "Port" => $Port));
// Flush the cache
DB_Accessor::FlushMemCache("Servers");
}
示例2: AddItemAction
public static function AddItemAction($ItemID, $ActionType, $ActionData, $Servers)
{
// Make it in the database
Database::Insert(self::$TableName, array("ItemID" => $ItemID, "ActionType" => $ActionType, "ActionData" => $ActionData, "Servers" => $Servers));
// Flush the cache
DB_Accessor::FlushMemCache("ItemAction");
}
示例3: Insert
function Insert($path, $module, $item, $safeInsert = true, $language = false)
{
global $_JAM;
// Use default language if none is provided
if (!$language) {
$language = $_JAM->defaultLanguage;
}
// Disable all paths that represent exactly the same resource
$params = array('current' => false);
$where = array('module = ' . (int) $module, 'item = ' . (int) $item, "language = '" . $language . "'");
if (!Database::Update('_paths', $params, $where)) {
trigger_error("Couldn't disable other paths representing the same resource", E_USER_WARNING);
return false;
}
// Convert to lower ASCII
$path = String::ToLowerASCII($path);
// Replace spaces with %20
$path = str_replace(' ', '%20', $path);
// Check whether path already exists
if ($duplicate = $_JAM->paths[$path]) {
// Path already exists
if ($duplicate['module'] == $module && $duplicate['item'] == $item && $duplicate['language'] == $language) {
// This path represents the same resource; enable it and we're done
$params = array('current' => true);
if (Database::Update('_paths', $params, 'id = ' . $duplicate['id'])) {
return $path;
} else {
return false;
}
} else {
// This path represents another resource
if ($safeInsert) {
// We don't want to overwrite the existing path; find the next unique path
$basePath = $path;
$i = 1;
while ($_JAM->paths[$path] && $i++ < 999) {
$path = $basePath . '_' . $i;
}
} else {
// We want to force this URL by overwriting the duplicate path
if (Database::Update('_paths', $params, 'path = ' . $path)) {
// That's it, we're done
return $path;
} else {
trigger_error("Couldn't overwrite duplicate path", E_USER_ERROR);
}
}
}
}
// Insert path
$params = array('path' => $path, 'current' => true, 'module' => $module, 'item' => $item, 'language' => $language);
if (Database::Insert('_paths', $params)) {
return $path;
} else {
trigger_error("Couldn't insert path into database");
return false;
}
}
示例4: OnUserBuy
public function OnUserBuy($UserObj)
{
$this->ChangeValue("NumPurchases", $this->GetValue("NumPurchases") + 1);
// Give them all actions associated with this item
foreach (ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID")) as $ItemActionObj) {
$ItemActionObj->GiveToUser($UserObj);
}
Database::Insert("gmd_purchases", array("ItemID" => $this->GetValue("ID"), "UserID" => $UserObj->GetValue("ID"), "Date" => time(), "PurchasingIP" => $_SERVER["REMOTE_ADDR"], "PaymentAmount" => $this->GetValue("Cost")));
}
示例5: MakeCategory
public static function MakeCategory($CatName)
{
if (empty($CatName)) {
return;
}
// Make it in the database
Database::Insert(self::$TableName, array("Name" => $CatName));
// Flush the cache
DB_Accessor::FlushMemCache("ItemCategory");
}
示例6: read
public function read($id)
{
$data = Database::GetOne("sessions", array("sess_id" => $id));
if (is_array($data)) {
Database::Edit("sessions", array("sess_id" => $id), array("sess_id" => $id, "time" => time()));
return $data['data'];
} else {
Database::Insert("sessions", array("sess_id" => $id, "time" => time()));
return "";
}
}
示例7: PostProcessData
function PostProcessData($id)
{
foreach ($this->participants as $participant) {
$params = $participant;
$params['contribution'] = $id;
if (!Database::Insert('participants', $params)) {
trigger_error("Couldn't insert data for child module", E_USER_ERROR);
return false;
}
}
}
示例8: actionHandler
public function actionHandler()
{
$last_id = isset($_POST['last_id']) ? (int) $_POST['last_id'] : 0;
$result = array();
if (!empty($_POST['text'])) {
$sth = Database::Insert("chat", array('user' => char()->name, 'text' => $_POST['text'], 'date' => time()));
}
$sth = Database::Get("chat", array('date' => array('$gt' => $last_id)))->sort(array('date' => 1));
foreach ($sth as $o) {
$result[] = $o;
}
echo json_encode($result);
}
示例9: register
public static function register($login, $password, $email)
{
if (empty($login)) {
raptor_error("Trying to register player with no login");
}
if (empty($password)) {
raptor_error("Trying to register player with no password");
}
if (empty($email)) {
raptor_error("Trying to register player with no email");
}
$check = Database::GetOne("players", array("login" => $login));
if (isset($check['login'])) {
return false;
}
$playerid = new MongoId();
Database::Insert("players", array("login" => $login, "password" => md5($password), "email" => $email, "reg_ip" => $_SERVER['REMOTE_ADDR'], "last_ip" => $_SERVER['REMOTE_ADDR'], "last_date" => raptor_date(), "_id" => $playerid));
return $playerid;
}
示例10: AddUploadedFile
function AddUploadedFile($field)
{
global $_JAM;
$tempFilename = $_FILES[$field]['tmp_name'];
$this->originalFilenames[$field] = $_FILES[$field]['name'];
$fileType = $_FILES[$field]['type'];
// If we lack a filetype, try to use GetID3 to figure it out
if (!$filetype) {
$getID3 = new getID3();
if ($fileInfo = $getID3->analyze($tempFilename)) {
$fileType = $fileInfo['mime_type'] ? $fileInfo['mime_type'] : '';
}
}
// Make sure this is a legitimate PHP file upload
if (!is_uploaded_file($tempFilename)) {
trigger_error("There is no legitimate uploaded file", E_USER_ERROR);
return false;
}
// Insert into files table
$params = array('filename' => $this->originalFilenames[$field], 'type' => $fileType);
if (!Database::Insert('files', $params)) {
trigger_error("Couldn't insert file into database", E_USER_ERROR);
}
// Get just-inserted ID of file in files table
$fileID = Database::GetLastInsertID();
// Files are named with their ID
$destinationFile = $_JAM->filesDirectory . $fileID;
// Move file to destination directory
if (!move_uploaded_file($tempFilename, $destinationFile)) {
// Move failed
if (!Database::DeleteFrom('files', 'id = ' . $fileID)) {
trigger_error("Couldn't delete database entry for nonexistent file", E_USER_ERROR);
}
trigger_error("Couldn't move temporary file to files directory", E_USER_ERROR);
return false;
}
// Delete previous item if applicable
$previousFileID = $this->parentModule->postData[$field];
if (!$this->parentModule->config['keepVersions'] && $previousFileID) {
$this->DeleteItem($previousFileID);
}
return $fileID;
}
示例11: raptor_print
raptor_print('PGRpdiBjbGFzcz0id2VsbCI+0KHQtdC50YfQsNGBINCy0LDQvCDQv9GA0LXQtNGB0YLQvtC40YIg0LLQstC10YHRgtC4INC+0YHQvdC+0LLQvdGL0LUg0LTQsNC90L3Ri9C1INCx0LDQt9GLLiDQndCw0LnQtNC40YLQtSDQsiDQv9Cw0L/QutC1IGVuZ2luZSDRhNCw0LnQuyBjb25maWcucGhwLmRpc3Qg0Lgg0L/QtdGA0LXQuNC80LXQvdGD0LnRgtC1INC10LPQviDQsiBjb25maWcucGhwIDxicj4g0J/QvtGC0L7QvCDQvtGC0LrRgNC+0LnRgtC1INC70Y7QsdGL0Lwg0YLQtdC60YHRgtC+0LLRi9C8INGA0LXQtNCw0LrRgtC+0YDQvtC8INC4INCy0LLQtdC00LjRgtC1INGC0YDQtdCx0YPQtdC80YvQtSDQtNCw0L3QvdGL0LUsINGB0LvQtdC00YPRjyDQv9C+0LTRgdC60LDQt9C60LDQvCDQsiDRhNCw0LnQu9C1LiDQnNGLINC/0L7QtNC+0LbQtNGR0LwsINC/0L7QutCwINCy0Ysg0LfQsNC60L7QvdGH0LjRgtC1LCDQv9C+0YHQu9C1INC90LDQttC80LjRgtC1INC60L3QvtC/0LrRgyDQlNCw0LvRjNGI0LU8L2Rpdj4NCgkJCTxwPjxhIGhyZWY9Ij9zdGVwPTMiIGNsYXNzPSJidG4gYnRuLXByaW1hcnkgYnRuLWxnIiByb2xlPSJidXR0b24iPtCU0LDQu9GM0YjQtSDCuzwvYT48L3A+');
} else {
raptor_print('PGRpdiBjbGFzcz0id2VsbCI+0KHQtdC50YfQsNGBINCy0LDQvCDQv9GA0LXQtNGB0YLQvtC40YIg0LLQstC10YHRgtC4INC+0YHQvdC+0LLQvdGL0LUg0LTQsNC90L3Ri9C1INCx0LDQt9GLLiDQndCw0LnQtNC40YLQtSDQsiDQv9Cw0L/QutC1IGVuZ2luZSDRhNCw0LnQuyBjb25maWcucGhwLCDQvtGC0LrRgNC+0LnRgtC1INC70Y7QsdGL0Lwg0YLQtdC60YHRgtC+0LLRi9C8INGA0LXQtNCw0LrRgtC+0YDQvtC8INC4INCy0LLQtdC00LjRgtC1INGC0YDQtdCx0YPQtdC80YvQtSDQtNCw0L3QvdGL0LUsINGB0LvQtdC00YPRjyDQv9C+0LTRgdC60LDQt9C60LDQvCDQsiDRhNCw0LnQu9C1LiDQnNGLINC/0L7QtNC+0LbQtNGR0LwsINC/0L7QutCwINCy0Ysg0LfQsNC60L7QvdGH0LjRgtC1LCDQv9C+0YHQu9C1INC90LDQttC80LjRgtC1INC60L3QvtC/0LrRgyDQlNCw0LvRjNGI0LU8L2Rpdj4NCgkJCTxwPjxhIGhyZWY9Ij9zdGVwPTMiIGNsYXNzPSJidG4gYnRuLXByaW1hcnkgYnRuLWxnIiByb2xlPSJidXR0b24iPtCU0LDQu9GM0YjQtSDCuzwvYT48L3A+');
}
} else {
raptor_print('PGRpdiBjbGFzcz0iYWxlcnQgYWxlcnQtZGFuZ2VyIj48Yj5jb25maWcucGhwLmRpc3Q8L2I+INC+0YLRgdGD0YLRgdGC0LLRg9C10YIg0LIg0L/QsNC/0LrQtSBlbmdpbmUuINCj0LHQtdC00LjRgtC10YHRjCDQsiDRhtC10LvQvtGB0YLQvdC+0YHRgtC4INC00LDQvdC90YvRhS4g0JXRgdC70Lgg0LLRiyDRg9Cy0LXRgNC10L3Riywg0YfRgtC+INGE0LDQudC7INGC0LDQvCDQtdGB0YLRjCwg0L/QtdGA0LXQuNC80LXQvdGD0LnRgtC1INC10LPQviDQsiBjb25maWcucGhwINC4INC90LDQv9C+0LvQvdC40YLQtSwg0YHQu9C10LTRg9GPINC60L7QvNC80LXQvdGC0LDRgNC40Y/QvCDQsiDQutC+0LTQtTwvZGl2Pg==');
}
break;
case 3:
if (isset($_POST['name'])) {
$in = array('modules' => array(), 'active' => '1', 'id' => uniqid()) + $_POST;
Database::Insert("config", $in);
foreach ($config as $as) {
Database::Insert("config", $as);
}
Database::Insert("scripts", array('name' => 'main', 'code' => 'ZnVuY3Rpb24gc2NyaXB0RW5naW5lSW5pdCgpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIG9uUGxheWVyTG9naW4oJGxvZ2luLCAkcGFzc3dvcmQsICRzdWNjZXNzKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblBsYXllclJlZ2lzdGVyKCRsb2dpbiwgJHBhc3N3b3JkLCAkZW1haWwpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIEV2ZW50VGltZXJFeHBpcmVkKCRpZCkgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gVXNlSXRlbSgkaWQsICRpdGVtKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblJvdXRlZCgkZHJpdmVyLCAkYWN0aW9uLCAkbGluaykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25DbGllbnRDYWxsKCRpbnB1dCwgJHBhcmFtcykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25BcGlNZXRob2RDYWxsZWQoJG1ldGhvZCwgJHJlcXVlc3QpIHsNCiAgcmV0dXJuIGZhbHNlOw0KfQ0KDQpmdW5jdGlvbiBvbkRpYWxvZ1Jlc3BvbnNlKCRkaWFsb2dpZCwgJGFuc3dlcikgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25QbGF5ZXJDb250ZXh0TWVudSgkbGlzdGl0ZW0sICR0YXJnZXQpIHsNCiAgcmV0dXJuIDE7DQp9'));
echo "<div class='alert alert-success'>База данных заполнена. <a href='?step=4'>Перейти к последнему шагу</a></div>";
}
raptor_print('PGZvcm0gYWN0aW9uPSIiIG1ldGhvZD0iUE9TVCI+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPtCd0LDQt9Cy0LDQvdC40LUg0LjQs9GA0Ys8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9Im5hbWUiIHZhbHVlPSIiPg0KCQk8L2Rpdj4NCgkJPGRpdiBjbGFzcz0iZm9ybS1ncm91cCI+DQoJCQk8bGFiZWw+0JLQtdGA0YHQuNGPINC40LPRgNGLPC9sYWJlbD4NCgkJCTxpbnB1dCBjbGFzcz0iZm9ybS1jb250cm9sIiBuYW1lPSJ2ZXJzaW9uIiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPlB1YmxpYyBLZXkgKNC/0YPQsdC70LjRh9C90YvQuSDQutC70Y7RhyDQtNC70Y8gQVBJKTwvbGFiZWw+DQoJCQk8aW5wdXQgY2xhc3M9ImZvcm0tY29udHJvbCIgbmFtZT0icHVibGljX2tleSIgdmFsdWU9IiI+DQoJCTwvZGl2Pg0KCQk8ZGl2IGNsYXNzPSJmb3JtLWdyb3VwIj4NCgkJCTxsYWJlbD5Qcml2YXRlIEtleSAo0L/RgNC40LLQsNGC0L3Ri9C5INC60LvRjtGHINC00LvRjyBBUEk7INC90LUg0YHQvtC+0LHRidCw0LnRgtC1INC10LPQviDRgdGC0L7RgNC+0L3QvdC40Lwg0LvQuNGG0LDQvCk8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9InByaXZhdGVfa2V5IiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxidXR0b24gdHlwZT0ic3VibWl0IiBjbGFzcz0iYnRuIGJ0bi1kZWZhdWx0Ij7QodC+0YXRgNCw0L3QuNGC0Yw8L2J1dHRvbj4NCgk8L2Zvcm0+');
break;
case 4:
if (isset($_POST['name'])) {
$id = Player::register($_POST['name'], $_POST['password'], $_POST['email']);
Char::create(array('name' => $_POST['name'], 'player' => $id, 'about' => $_POST['about'], 'admin' => '1'));
if (file_put_contents(CACHE_ROOT . SEPARATOR . "installed.cache", "What are you looking for, admin?")) {
echo '<h3>Игра полностью установлена. <a href="/">Вход</a></h3>';
} else {
echo '<h3>Ошибка при создании файла завершения установки. <a href="?step=4&file=1">Повторить попытку</a></h3>';
}
}
if (isset($_GET['file'])) {
示例12: array
<?php
include_once 'Libraries/Database.php';
$response = array();
$databaseconnection = new Database();
if ($_GET['serialNumber'] && $_GET['simImei'] && $_GET['softwareVersion']) {
$serialNumber = $_GET['serialNumber'];
$simImei = $_GET['simImei'];
$softwareVersion = $_GET['softwareVersion'];
$qeury = "insert into smsinformation(Sim_SerialNumber,Sim_IMEI,SoftwareVersion)\n\t values('{$serialNumber}','{$simImei}','{$softwareVersion}')";
$insert = $databaseconnection->Insert($qeury);
if ($insert) {
$response['success'] = "1";
$response['message'] = "data Enter Successfully";
echo json_encode($response);
} else {
$response['success'] = "0";
$response['message'] = "Ops ! data not Enter";
echo json_encode($response);
}
} else {
$response['success'] = "0";
$response['message'] = "Column not Found";
echo json_encode($response);
}
示例13: key
$rg_groupid = '8';
if ($rg_ifcheck == '1') {
$rg_groupid = '7';
//后台控制是否需要验证
}
require_once 'data/bbscache/level.php';
@asort($lneed);
$rg_memberid = key($lneed);
$rg_yz = $rg_emailcheck == 1 ? $timestamp : 1;
//是否接受邮件
$regifemail = Request('regifemail');
$rg_ifemail = (int) $regifemail;
//插入会员表
$ArrField = array('username', 'password', 'email', 'groupid', 'icon', 'gender', 'regdate', 'signature', 'introduce', 'oicq', 'site', 'location', 'bday', 'yz');
$ArrValue = array($rg_name, $rg_pwd, $rg_email, $rg_groupid, $regicon, $rg_sex, TIMESTAMP, $rg_sign, $rg_introduce, $rg_oicq, $rg_homepage, $rg_from, $rg_birth, $rg_yz);
if ($MyDatabase->Insert('users', $ArrField, $ArrValue)) {
$winduid = $MyDatabase->Insert_id();
} else {
echo '添加会员失败!';
DebugStr($MyDatabase->SqlStr);
exit;
}
//插入会员扩展数据表
$ArrField = array('uid', 'postnum', 'rvrc', 'money', 'lastvisit', 'thisvisit', 'onlineip');
$ArrValue = array($winduid, 0, $rg_regrvrc, $rg_regmoney, TIMESTAMP, TIMESTAMP, ONLINEIP);
if ($MyDatabase->Insert('user_ext', $ArrField, $ArrValue)) {
} else {
echo '添加会员扩展数据失败!';
exit;
}
//更新论坛信息,最新会员,总会员数
示例14: trigger_error
if (!Database::CreateTable($name, $schema)) {
trigger_error("Couldn't create table " . $name, E_USER_ERROR);
}
}
// Manually add admin module to _modules table
if (Query::TableIsEmpty('_modules')) {
$adminModule = array('name' => 'admin');
if (!Database::Insert('_modules', $adminModule)) {
trigger_error("Couldn't install core modules", E_USER_ERROR);
}
}
// Install required modules
$requiredModules = array('users', 'files');
foreach ($requiredModules as $moduleName) {
$module = Module::GetNewModule($moduleName);
$module->Install();
}
// Add default admin user
if (Query::TableIsEmpty('users')) {
$adminUserParams = array('created' => $_JAM->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
if (!Database::Insert('users', $adminUserParams)) {
trigger_error("Couldn't create admin user", E_USER_ERROR);
}
}
// Add admin path
$adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
if (!Path::Insert('admin', $adminModuleId, false)) {
trigger_error("Couldn't add admin path", E_USER_ERROR);
}
// Redirect to admin interface
HTTP::RedirectLocal('admin');
示例15: start_unzip
function start_unzip($tmp_name, $new_name, $checked)
{
global $_POST, $z, $have_zip_file, $ImageUrl, $ImagePath;
$TheString = '';
$upfile = array("tmp_name" => $tmp_name, "name" => $new_name);
if (is_file($upfile['tmp_name'])) {
$have_zip_file = 1;
// echo "<br>正在解压: ".$upfile['name']."<br><br>";
if (preg_match('/\\.zip$/mis', $upfile['name'])) {
$result = $z->Extract($upfile['tmp_name'], $ImagePath);
//Zerolone Add 2008年9月21日17:52:43
foreach ($result as $key => $value) {
// echo "Key: $key<br />\n";
//入库
$MyDatabase = new Database();
$MyDatabase->Insert('article_pic', array('url'), array($ImageUrl . $key));
$TheString .= '<img src="' . $ImageUrl . $key . '"><br>';
}
return $TheString;
if ($result == -1) {
// echo "<br>文件". $upfile['name']. "错误.<br>";
}
// echo "<br>完成,共建立 $z->total_files 个文件.<br><br><br>";
} else {
// echo "<br>$upfile[name] 不是 zip 文件.<br><br>";
}
/*
if(realpath($upfile['name'])!=realpath($upfile['tmp_name'])){
@unlink($upfile['name']);
rename($upfile['tmp_name'],$upfile['name']);
}
*/
}
}