本文整理汇总了PHP中Parse\ParseObject::setAssociativeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseObject::setAssociativeArray方法的具体用法?PHP ParseObject::setAssociativeArray怎么用?PHP ParseObject::setAssociativeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseObject
的用法示例。
在下文中一共展示了ParseObject::setAssociativeArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add()
{
// validators
$this->form_validation->set_error_delimiters($this->config->item('error_delimeter_left'), $this->config->item('error_delimeter_right'));
$this->form_validation->set_rules('user_id', lang('reservations input user_id'), 'trim');
$this->form_validation->set_rules('team_id', lang('reservations input team_id'), 'trim');
$this->form_validation->set_rules('match_data[date]', lang('reservations input date'), 'required|trim');
$this->form_validation->set_rules('match_data[time]', lang('reservations input time'), 'required|trim');
$this->form_validation->set_rules('match_data[duration]', lang('reservations input duration'), 'required|trim|numeric');
if ($this->form_validation->run() == true) {
$data = $this->input->post();
// save the new user
$reservation = new ParseObject("Reservation");
$relationOwner = $reservation->getRelation("userId");
$queryOwner = ParseUser::query();
$owner = $queryOwner->get("btPTAhtpvo");
$relationOwner->add($owner);
$relationStatus = $reservation->getRelation("status");
$queryStatus = new ParseQuery("ReservationStatus");
$status = $queryStatus->get("KIzDQVJrAV");
$relationStatus->add($status);
$reservation->setAssociativeArray("reservationData", $data['match_data']);
try {
$reservation->save();
$this->session->set_flashdata('message', 'New object created with objectId: ' . $reservation->getObjectId());
redirect($this->_redirect_url);
} catch (ParseException $ex) {
// Execute any logic that should take place if the save fails.
// error is a ParseException object with an error code and message.
$this->session->set_flashdata('error', 'Failed to create new object, with error message: ' . $ex->getMessage());
}
// return to list and display message
}
// setup page header data
// setup page header data
$this->set_title(sprintf(lang('reservations title reservations'), $this->settings->site_name));
$this->set_subtitle(lang('reservations subtitle add_reservation'));
$data = $this->includes;
// set content data
$content_data = array('cancel_url' => $this->_redirect_url, 'user' => null, 'password_required' => true);
// load views
$data['content'] = $this->load->view('reservations/form', $content_data, true);
$this->load->view($this->template, $data);
}
示例2: setValues
/**
* @param array $data
* @param ParseObject $parseObject
*
* @return mixed
*/
protected function setValues(array $data, $parseObject)
{
foreach ($data as $key => $value) {
// If it's an array, we need to use different setter methods
if (is_array($value)) {
// Associative array
if (count(array_filter(array_keys($value), 'is_string'))) {
$parseObject->setAssociativeArray($key, $value);
} else {
$parseObject->setArray($key, $value);
}
} else {
$parseObject->set($key, $value);
}
}
return $parseObject->save($this->useMasterKey);
}
示例3: ParseObject
use Parse\ParsePush;
// Start the session
session_start();
$app_id = "kddcodGlyJ6DmGI7FihXt8BsXyOTS09Dgpj8UA49";
$rest_key = "ryU6g6D37JtDqIAnPbTq4SLNmihEIy8kSNPZxlhj";
$master_key = "Fm9X40ewplSIEDTOmYxVdCEN7ge31vgfFwScYr3y";
ParseClient::initialize($app_id, $rest_key, $master_key);
if (isset($_SESSION["username"])) {
if (isset($_POST["message"]) && $_POST["message"] != "" && strlen($_POST["message"]) <= 255 && isset($_POST["inputEmail"]) && $_POST["inputEmail"] != "") {
$ping = new ParseObject("Pings");
$ping->set("Title", "TLC Helpdesk");
//Auto set, we change later if need be
$ping->set("Message", $_POST["message"]);
//$newDate = getProperDateFormat(new DateTime());
$date = array("__type" => "Date", "iso" => date("c"));
$ping->setAssociativeArray("Date", $date);
try {
$query = new ParseQuery($class = '_User');
$query->equalTo("username", $_POST["inputEmail"]);
$user = $query->first();
//print $_POST["inputEmail"]."<br>";
//print_r($user);
//print "Made it <br>";
$relation = $ping->getRelation("User");
//print "Made it 2<br>";
//print_r($relation);
$relation->add($user);
//print "Made it 3<br>";
$ping->save();
} catch (ParseException $ex) {
/* Should pass back a cookie with the error $ex->getMessage() */
示例4: do_create
public function do_create(array $params = [])
{
$mark = array();
for ($x = 0; $x < count($_POST['title']); $x++) {
$tag = new ParseObject("BrandTag");
$tag->set("xCoordinate", (double) $_POST['x'][$x]);
$tag->set("yCoordinate", (double) $_POST['y'][$x]);
$tag->set("tagName", $_POST['title'][$x]);
$tag->save();
$query = new ParseQuery("BrandTag");
$query->descending("createdAt");
$object = $query->first();
$id = $object->getObjectId();
$mark[] = array('__type' => 'Pointer', 'className' => 'BrandTag', 'objectId' => '' . $id . '');
}
$gameScore = new ParseObject("BrandPost");
$gameScore->setArray("tagArray", $mark);
$gameScore->set("brandName", $_POST['brandName']);
$gameScore->set("content", $_POST['content']);
if (isset($_POST['items'])) {
$it = array();
foreach ($_POST['items'] as $item) {
$it[] = array('__type' => 'Pointer', 'className' => 'BrandItem', 'objectId' => '' . $item . '');
$gameScore->setArray("brandItems", $it);
}
}
$gameScore->setAssociativeArray("Brand", array('__type' => 'Pointer', 'className' => 'Brand', 'objectId' => $_POST['brand']));
if (isset($_FILES['image']) && !empty($_FILES['image'])) {
if (($_FILES["image"]["type"] == "image/png" || $_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/jpeg") && $_FILES["image"]["size"] < 10000000) {
$file = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $_FILES['image']['name']);
$file->save();
$gameScore->set("postImage", $file);
}
}
$query = new ParseQuery("Brand");
$query->equalTo("objectId", $_POST['brand']);
$question = $query->first();
$n_of_p = $question->numberOfPosts + 1;
$question->set("numberOfPosts", $n_of_p);
$question->save();
$gameScore->save();
@($this->template = false);
redirect(ADMIN_URL . 'brand_post');
}
示例5: order
public function order()
{
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
// do stuff with the user
} else {
// show the signup or login page
Url::redirect('login');
}
if (isset($_POST['table'])) {
View::render('inventory/order-table', $data, $error);
} elseif (isset($_POST['del']) && isset($_POST['objectId'])) {
$objectId = $_POST['objectId'];
$query = new ParseQuery('Order');
try {
$data = 1;
} catch (ParseException $ex) {
$data = $ex;
}
$query->equalTo('objectId', $objectId);
$order = $query->first();
$order->destroy();
header('Content-type: application/json; charset=utf-8');
echo json_encode(array('result' => $data));
} elseif (isset($_POST['update'])) {
$objectId = !isset($_POST['objectId']) || trim($_POST['objectId']) == '' ? '' : $_POST['objectId'];
$productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId'];
$productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
$customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId'];
$customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName'];
$lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId'];
$facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook'];
$telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone'];
$transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']);
$address = !isset($_POST['address']) || trim($_POST['address']) == '' ? '' : $_POST['address'];
$transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus'];
$transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus'];
$trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber'];
$contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook];
if ($_FILES['fileToUpload']['size'] > 0) {
$target_file = basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
//echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
//echo "File is not an image.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
$error = "Sorry, your file is too large." . $error;
$uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$error = "Sorry, your file was not uploaded." . $error;
// if everything is ok, try to upload file
} else {
$imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
$query = new ParseQuery('Order');
$query->equalTo('objectId', $objectId);
$order = $query->first();
$order->set('productId', $productId);
$order->set('productName', $productName);
$order->set('customerName', $customerName);
$order->set('customerId', $customerId);
$order->setAssociativeArray('contact', $contact);
$order->set('slipPayin', $imageFile);
$order->set('transportDate', $transportDate);
$order->set('address', $address);
$order->set('transportStatus', $transportStatus);
$order->set('transferStatus', $transferStatus);
$order->set('trackingNumber', $trackingNumber);
$order->save();
}
} else {
$query = new ParseQuery('Order');
$query->equalTo('objectId', $objectId);
$order = $query->first();
$order->set('productId', $productId);
$order->set('productName', $productName);
$order->set('customerName', $customerName);
$order->set('customerId', $customerId);
$order->setAssociativeArray('contact', $contact);
$order->set('transportDate', $transportDate);
$order->set('address', $address);
$order->set('transportStatus', $transportStatus);
$order->set('transferStatus', $transferStatus);
$order->set('trackingNumber', $trackingNumber);
$order->save();
}
} else {
//.........这里部分代码省略.........