本文整理汇总了PHP中DBObject::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::insert方法的具体用法?PHP DBObject::insert怎么用?PHP DBObject::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObject
的用法示例。
在下文中一共展示了DBObject::insert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
function insert($force_validation = false)
{
if (!$this->report_key) {
$this->report_key = uniqid();
}
// insert feed into database
parent::insert();
}
示例2: create
static function create($user_id, $payment_hash, $days, $amount)
{
$dbInsert = new DBObject("premium_order", array("user_id", "payment_hash", "days", "amount", "order_status", "date_created"));
$dbInsert->user_id = $user_id;
$dbInsert->payment_hash = $payment_hash;
$dbInsert->days = $days;
$dbInsert->amount = $amount;
$dbInsert->order_status = 'pending';
$dbInsert->date_created = date("Y-m-d H:i:s", time());
if ($dbInsert->insert()) {
return $dbInsert;
}
return false;
}
示例3: create
static function create($username, $password, $email, $title, $firstname, $lastname, $accType = 'user')
{
$dbInsert = new DBObject("users", array("username", "password", "email", "title", "firstname", "lastname", "datecreated", "createdip", "status", "level", "paymentTracker"));
$dbInsert->username = $username;
$dbInsert->password = MD5($password);
$dbInsert->email = $email;
$dbInsert->title = $title;
$dbInsert->firstname = $firstname;
$dbInsert->lastname = $lastname;
$dbInsert->datecreated = sqlDateTime();
$dbInsert->createdip = getUsersIPAddress();
$dbInsert->status = 'active';
$dbInsert->level = 'free user';
$dbInsert->paymentTracker = MD5(time() . $username);
if ($dbInsert->insert()) {
return $dbInsert;
}
return false;
}
示例4: getTranslation
static function getTranslation($key, $defaultContent = '')
{
/* are we in language debug mode */
if (SITE_CONFIG_LANGUAGE_SHOW_KEY == "key") {
return strlen($defaultContent) ? $defaultContent : $key;
}
/* return the language translation if we can find it */
$constantName = "LANGUAGE_" . strtoupper($key);
if (!defined($constantName)) {
if (strlen($defaultContent)) {
$db = Database::getDatabase();
$languageId = $db->getValue("SELECT id FROM language WHERE languageName = " . $db->quote(SITE_CONFIG_SITE_LANGUAGE));
if (!(int) $languageId) {
return false;
}
// insert default key value
$dbInsert = new DBObject("language_key", array("languageKey", "defaultContent", "isAdminArea"));
$dbInsert->languageKey = $key;
$dbInsert->defaultContent = $defaultContent;
$dbInsert->isAdminArea = 0;
$dbInsert->insert();
// set constant
define("LANGUAGE_" . strtoupper($key), $defaultContent);
return $defaultContent;
}
return "<font style='color:red;'>SITE ERROR: MISSING TRANSLATION *** <strong>" . $key . "</strong> ***</font>";
}
return constant($constantName);
}
示例5: foreach
$userId = $order->user_id;
// log in payment_log
$paypal_vars = "";
foreach ($_REQUEST as $k => $v) {
$paypal_vars .= $k . " => " . $v . "\n";
}
$dbInsert = new DBObject("payment_log", array("user_id", "date_created", "amount", "currency_code", "from_email", "to_email", "description", "request_log"));
$dbInsert->user_id = $userId;
$dbInsert->date_created = date("Y-m-d H:i:s", time());
$dbInsert->amount = $_REQUEST['mc_gross'];
$dbInsert->currency_code = $_REQUEST['mc_currency'];
$dbInsert->from_email = $_REQUEST['payer_email'];
$dbInsert->to_email = $_REQUEST['business'];
$dbInsert->description = $extendedDays . ' days extension';
$dbInsert->request_log = $paypal_vars;
$dbInsert->insert();
// make sure the amount paid matched what we expect
if ($_REQUEST['mc_gross'] != $order->amount) {
// order amounts did not match
die;
}
// make sure the order is pending
if ($order->order_status == 'completed') {
// order has already been completed
die;
}
// update order status to paid
$dbUpdate = new DBObject("premium_order", array("order_status"), 'id');
$dbUpdate->order_status = 'completed';
$dbUpdate->id = $order->id;
$effectedRows = $dbUpdate->update();
示例6: json_encode
require_once 'ajax_auth.inc.php';
$db = Database::getDatabase();
/* get vars */
$params = json_decode($_REQUEST['value']);
$language_name = trim($params->group1->language_name);
$response = array();
$response['content'] = "";
$response['javascript'] = "";
$response['errors'] = array();
$response['success'] = 1;
/* validate submission */
/* check to see if it exists in db */
$db = Database::getDatabase(true);
$row = $db->getRow('SELECT id FROM language WHERE languageName = ' . $db->quote($language_name));
if (is_array($row)) {
$response['errors']['language_name'] = array(t("language_already_in_system"));
}
/* insert/update db */
if (COUNT($response['errors']) == 0) {
/* create the intial record */
$dbInsert = new DBObject("language", array("languageName"));
$dbInsert->languageName = $language_name;
if (!$dbInsert->insert()) {
$response['errors']['language_name'] = array(t("error_problem_record"));
}
}
if (COUNT($response['errors']) > 0) {
$response['success'] = 0;
}
echo json_encode($response);
示例7: handle_file_upload
//.........这里部分代码省略.........
$file_path = $uploadPathDir . '/' . $newFilename;
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// initiate ftp
$ret = ftp_nb_put($conn_id, $file_path, $uploaded_file, FTP_BINARY, FTP_AUTORESUME);
while ($ret == FTP_MOREDATA) {
// continue uploading
$ret = ftp_nb_continue($conn_id);
}
if ($ret != FTP_FINISHED) {
$fileUpload->error = 'There was a problem uploading the file to ' . $uploadServerDetails['ipAddress'];
} else {
$file_size = filesize($uploaded_file);
@unlink($uploaded_file);
}
}
}
// close ftp connection
ftp_close($conn_id);
} else {
// create the upload folder
$uploadPathDir = $this->options['upload_dir'] . substr($newFilename, 0, 2);
@mkdir($uploadPathDir);
$file_path = $uploadPathDir . '/' . $newFilename;
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
move_uploaded_file($uploaded_file, $file_path);
}
$file_size = filesize($file_path);
}
// check filesize uploaded matches tmp uploaded
if ($file_size === $fileUpload->size) {
$fileUpload->url = $this->options['upload_url'] . rawurlencode($fileUpload->name);
// insert into the db
$fileUpload->size = $file_size;
$fileUpload->delete_url = '~d?' . $this->options['delete_hash'];
$fileUpload->info_url = '~i?' . $this->options['delete_hash'];
$fileUpload->delete_type = 'DELETE';
// create delete hash, make sure it's unique
$deleteHash = md5($fileUpload->name . getUsersIPAddress() . microtime());
$existingFile = file::loadByDeleteHash($deleteHash);
while ($existingFile != false) {
$deleteHash = md5($fileUpload->name . getUsersIPAddress() . microtime());
$existingFile = file::loadByDeleteHash($deleteHash);
}
// store in db
$db = Database::getDatabase(true);
$dbInsert = new DBObject("file", array("originalFilename", "shortUrl", "fileType", "extension", "fileSize", "localFilePath", "userId", "totalDownload", "uploadedIP", "uploadedDate", "statusId", "deleteHash", "serverId"));
$dbInsert->originalFilename = $fileUpload->name;
$dbInsert->shortUrl = 'temp';
$dbInsert->fileType = $fileUpload->type;
$dbInsert->extension = $extension;
$dbInsert->fileSize = $fileUpload->size;
$dbInsert->localFilePath = substr($file_path, strlen($this->options['upload_dir']), 99999);
// add user id if user is logged in
$dbInsert->userId = NULL;
$Auth = Auth::getAuth();
if ($Auth->loggedIn()) {
$dbInsert->userId = (int) $Auth->id;
}
$dbInsert->totalDownload = 0;
$dbInsert->uploadedIP = getUsersIPAddress();
$dbInsert->uploadedDate = sqlDateTime();
$dbInsert->statusId = 1;
$dbInsert->deleteHash = $deleteHash;
$dbInsert->serverId = $uploadServerId;
if (!$dbInsert->insert()) {
$fileUpload->error = 'abort';
}
// create short url
$tracker = 1;
$shortUrl = file::createShortUrlPart($tracker . $dbInsert->id);
$fileTmp = file::loadByShortUrl($shortUrl);
while ($fileTmp) {
$shortUrl = file::createShortUrlPart($tracker . $dbInsert->id);
$fileTmp = file::loadByShortUrl($shortUrl);
$tracker++;
}
// update short url
file::updateShortUrl($dbInsert->id, $shortUrl);
// update fileUpload with file location
$file = file::loadByShortUrl($shortUrl);
$fileUpload->url = $file->getFullShortUrl();
$fileUpload->delete_url = $file->getDeleteUrl();
$fileUpload->info_url = $file->getInfoUrl();
$fileUpload->stats_url = $file->getStatisticsUrl();
$fileUpload->short_url = $shortUrl;
} else {
if ($this->options['discard_aborted_uploads']) {
//@TODO - made ftp compatible
@unlink($file_path);
@unlink($uploaded_file);
if (!isset($fileUpload->error)) {
$fileUpload->error = 'maxFileSize';
}
}
}
}
return $fileUpload;
}