本文整理汇总了PHP中Db::selectCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::selectCollection方法的具体用法?PHP Db::selectCollection怎么用?PHP Db::selectCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::selectCollection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Db
<?php
// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("System");
$collection = $DB->selectCollection("Accounts");
$OUTPUT = new Output();
$REQUEST = new Request();
// get Password and Username from $REQUEST
$document = $collection->findOne(array('$or' => array(array("system_info.user" => $REQUEST->get("user")), array("system_info.email" => $REQUEST->get("user")))));
if (password_verify($REQUEST->get("password"), $document["system_info"]["hash"])) {
$lAT = bin2hex(openssl_random_pseudo_bytes(16));
// save $lAT into database
if ($REQUEST->avail("response_type") && $REQUEST->get("response_type") == "code") {
$collection->update(array("_id" => $document["_id"]), array('$addToSet' => array("system_info.OAuth_clients" => array("client_id" => $REQUEST->get("client_id"), "code" => $lAT))), array('multiple' => false, 'upsert' => true));
$OUTPUT->success(1, array("code" => $lAT));
die;
}
$collection->update(array("_id" => $document["_id"]), array('$set' => array("system_info.access_token" => $lAT)), array('multiple' => false, 'upsert' => true));
$OUTPUT->success(1, array("access_token" => $lAT, "user" => $document["system_info"]["user"]));
} else {
$OUTPUT->error(0, "Incorrect Username or Password");
}
示例2: Db
<?php
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Scoreboard");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Users");
$RULES = new Rules(1, "scoreboard");
$REQUEST = new Request();
$quantity = intval($REQUEST->get("quantity", "1"));
$asset_id = $REQUEST->get("asset_id");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$inc' => array("assets." . $asset_id . ".quantity" => $quantity)));
$LOG = new Logging("Scoreboard.asset");
$LOG->log($RULES->getId(), 61, $REQUEST->get("asset_id"), $quantity, "User added item to scoreboard Possessions");
$OUTPUT->success(0, $document, null);
示例3: Db
<?php
include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Messages");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
$query = array('root' => '1', array('participants' => $RULES->getId()));
$options = Helper::formatLimits($REQUEST);
$document = $collection->find($query, $options);
$OUTPUT->success(0, $document);
?>
示例4: Db
<?php
// Helpers and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("SocialNetwork");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Groups");
$update = Helper::updatePermitted($REQUEST);
$update = Helper::subDocUpdate($update, "providers.custom");
$options = Helper::formatOptions($REQUEST);
if ($REQUEST->avail("id")) {
$RULES = new Rules(5, "profile");
$document = $collection->findAndModify($REQUEST->get("id"), $update, $options);
} else {
$RULES = new Rules(1, "profile");
$document = $collection->findAndModify($RULES->getId(), $update, $options);
}
$OUTPUT->success(0, $document, null);
示例5: Db
<?php
include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("Auth");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Clients");
$REQUEST = new Request();
// client_id redirect_uri state response_type:code scope
$client_id = $REQUEST->get("client_id");
$redirect_uri = $REQUEST->get("redirect_uri");
$client_doc = $collection->findOne(array("client_id" => $client_id, "redirect_uri" => array('$elemMatch' => array('$in' => array($redirect_uri)))));
if ($REQUEST->get("response_type") != "code") {
echo "The response_type must be set to 'code' for this OAuth system";
die;
}
if (is_null($client_doc)) {
echo "An error occured, this client does not appear in the database, or the redirect URI does not match";
die;
}
if ($REQUEST->avail("state")) {
$state = $REQUEST->get("state");
$location = "{$redirect_uri}?state={$state}&code=";
} else {
$location = "{$redirect_uri}?code=";
}
?>
<html>
<head>
<script>
function Ajax(URL, data, callback){
var request = new XMLHttpRequest();
示例6: Db
<?php
/* Reformatted 12.11.2015 */
// Helpers and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Inventory");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// User needs to be logged in for access
$RULES = new Rules(1, "cart");
// Select Collection from Connection
$collectionName = Helper::getCollectionName($REQUEST, "Cart");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = array("user_id" => $RULES->getId());
// Used for anayltics
$LOG = new Logging("OAuth.query");
$LOG->log($RULES->getId(), 72, $query, 100, "OAuth Providers Queried");
// Format Limits (Skip, Limit)
$options = Helper::formatLimits($REQUEST);
// Find Documents
$documents = $collection->find($query, $options);
// Output
$OUTPUT->success(0, $documents);
?>
示例7: Db
<?php
// Helper functions and includs
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Cart");
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$cartName = $REQUEST->get("wishlist", "Default");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$push' => array("wishlist." . $cartName => MongoDBRef::create($collectionName, $REQUEST->get("id"), "Assets"))));
// Used for analytics
$LOG = new Logging("Cart.order");
$LOG->log($RULES->getId(), 43, $REQUEST->get("id"), 100, "User Wished for item");
$OUTPUT->success(0, $document, null);
示例8: Db
<?php
// Helper and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("System");
$OUTPUT = new Output();
$collection = $db->selectCollection("Contact");
$REQUEST = new Request();
$query = array("email_id" => $REQUEST->get("email_id"));
$document = $collection->findOne($query);
// Send mail
$to = trim(implode(" , ", $document["address"]), ' , ');
$subject = $REQUEST->get("subject");
$message = $REQUEST->get("body");
$sender = $REQUEST->avail("sender") ? $REQUEST->get("sender") : ($document["sender"] ? $document["sender"] : "noreply@" . $_SERVER["HTTP_HOST"]);
$headers = 'From: ' . $sender . "\r\n" . 'Reply-To: ' . $sender . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$result = mail($to, $subject, $message, $headers);
if ($result == 1) {
$OUTPUT->success(0, null, null);
} else {
$OUTPUT->error(2, "An Error occured in the mail function");
}
?>
示例9: save
public function save($access_token, $sId)
{
$OUTPUT = new Output();
$SESSION = new Session($sId);
$DB1 = new Db("System");
$System_users = $DB1->selectCollection("Users");
$DB2 = new Db("SocialNetwork");
$SN_users = $DB2->selectCollection("Users");
$provider = $SESSION->get("provider");
$base = $provider["base3"];
$params = array("access_token" => $access_token);
$meDoc = Helper::curl($base, $params, $access_token);
if (isset($meDoc["id"])) {
$id = $meDoc["id"];
} else {
if (isset($meDoc["_id"])) {
$id = $meDoc["_id"];
}
}
$provider_name = $provider["provider_name"];
$eAT = $SESSION->get("access_token");
if (!isset($eAT) || is_null($eAT)) {
// generate Lux access_token
// save into Session
$lAT = bin2hex(openssl_random_pseudo_bytes(16));
$SESSION->set("access_token", $lAT);
}
// find One where either access_token = access_token or providers.provider_name.id = $meDoc["id"]
// update providers.provider_name.access_token = $access_token
$System_users->update(array('$or' => array(array("providers.{$provider_name}.id" => $id), array("system_info.access_token" => $SESSION->get("access_token")))), array('$set' => array("system_info.access_token" => $SESSION->get("access_token"), "providers.{$provider_name}.id" => $id, "providers.{$provider_name}.access_token" => $access_token)), array("upsert" => true, "multiple" => false));
$AuthDoc = $System_users->findOne(array("system_info.access_token" => $SESSION->get("access_token")));
$SNDoc1 = array("providers.{$provider_name}" => $meDoc);
if (!isset($AuthDoc["SN_id"]) || is_null($AuthDoc["SN_id"])) {
// no SN_id exists
$SNDoc2 = array("providers" => array($provider_name => $meDoc));
$SN_users->insert($SNDoc2);
// if no SN_id exists, create a new one
$System_users->update(array("system_info.access_token" => $SESSION->get("access_token")), array('$set' => array('SN_id' => $SNDoc2["_id"])), array("multiple" => false, "upsert" => false));
} else {
// update providers.provider_name = meDoc where _id = SN_id
$SN_users->update(array("SN_id" => $AuthDoc["SN_id"]), array('$set' => $SNDoc1), array("multiple" => false, "upsert" => true));
}
}
示例10: selectCollection
/**
* Select Collection
*/
public function selectCollection($db_name, $collection_name)
{
$db = new Db((string) $db_name, $this);
$collection = $db->selectCollection($collection_name);
return $collection;
}
示例11: array
$postdata = http_build_query(array());
}
// build the HTTP request
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
// make the HTTP into a "context"
$context = stream_context_create($opts);
// make the actual request in context
$result = file_get_contents($document, false, $context);
$OUTPUT->success(1, null, $results);
} else {
$OUTPUT->error(2, "Service Could not be found");
}
$LF = new LuxFunctions();
$OUTPUT = new Output();
$DB = new Db("System");
$providers = $DB->selectCollection("providers");
$users = $DB->selectCollection("Users");
$provider_name = $LF->fetch_avail("provider");
$user = $users->findOne(array("lux_info.access_token" => $LF->fetch_avail("access_token")));
$access_token = $user["providers"][$provider_name]["access_token"];
$provider = $providers->findOne(array("provider_name" => $provider_name));
if (!$LF->is_avail("base")) {
$base = $provider["base4"];
} else {
$base = $LF->fetch_avail("base");
}
$params = $LF->getParameters();
unset($params["base"]);
unset($params["provider"]);
unset($params["path"]);
$params["access_token"] = $access_token;