本文整理汇总了PHP中UUID类的典型用法代码示例。如果您正苦于以下问题:PHP UUID类的具体用法?PHP UUID怎么用?PHP UUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
public function Execute($db, $params)
{
if (isset($params["SceneID"]) && UUID::TryParse($params["SceneID"], $this->SceneID)) {
$sql = "DELETE FROM Scenes WHERE ID='" . $this->SceneID . "'";
} else {
if (isset($params["Name"])) {
$sql = "DELETE FROM Scenes WHERE Name='" . $params["Name"] . "'";
} else {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
}
$sth = $db->prepare($sql);
if ($sth->execute()) {
header("Content-Type: application/json", true);
echo '{ "Success": true }';
exit;
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
}
示例2: Execute
public function Execute($db, $params)
{
// TODO: Sanity check the expiration date
// TODO: Also run a regex on Resource to make sure it's a valid (relative or absolute) URL
if (!isset($params["OwnerID"], $params["Resource"], $params["Expiration"]) || !UUID::TryParse($params["OwnerID"], $this->OwnerID)) {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) {
$this->CapabilityID = UUID::Random();
}
$resource = $params["Resource"];
$expiration = $params["Expiration"];
$sql = "INSERT INTO Capabilities (ID, OwnerID, Resource, ExpirationDate) VALUES (:ID, :OwnerID, :Resource, :ExpirationDate)\n ON DUPLICATE KEY UPDATE OwnerID=VALUES(OwnerID), Resource=VALUES(Resource), ExpirationDate=VALUES(ExpirationDate)";
$sth = $db->prepare($sql);
if ($sth->execute(array(':ID' => $this->CapabilityID, ':OwnerID' => $this->OwnerID, ':Resource' => $resource, ':ExpirationDate' => $expiration))) {
header("Content-Type: application/json", true);
echo sprintf('{"Success": true, "CapabilityID": "%s"}', $this->CapabilityID);
exit;
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
}
示例3: save_products
function save_products($link, $prenote_uuid, $product, $id_employee, $lastUpdate)
{
include 'config.php';
include_once '../class.uuid.php';
$handle = $link->prepare('INSERT INTO ' . $table_prenoteDetails . ' (ID, UUID, LastUpdate, CreationUserID, LastUpdateUserID, OperationOnHoldUUID, ItemUUID, ItemCombinationID, ItemCombinationUUID, ItemSerialID, ItemBarcode, UnitID, Quantity, UnitPrice, SalesPersonUserID, ParentID) VALUES (0, :UUID, :last_update, :create_id, :update_id, :prenote_uuid, :ItemUUID, :combinationID, :combinationUUID, :serialID, :barcode, :unitID, :Quantity, :Price, :id_employee, 0)');
$handle->bindParam(':UUID', $prenoteDetails_uuid);
$handle->bindParam(':last_update', $lastUpdate);
$handle->bindParam(':id_employee', $id_employee, PDO::PARAM_INT);
$handle->bindParam(':create_id', $id_employee, PDO::PARAM_INT);
$handle->bindParam(':update_id', $id_employee, PDO::PARAM_INT);
$handle->bindParam(':prenote_uuid', $prenote_uuid);
$handle->bindParam(':ItemUUID', $UUID);
$handle->bindParam(':unitID', $UnitID, PDO::PARAM_INT);
$handle->bindParam(':Quantity', $Quantity);
$handle->bindParam(':Price', $Price);
$handle->bindParam(':serialID', $serialID);
$handle->bindParam(':barcode', $barcode);
$handle->bindParam(':combinationID', $combinationID);
$handle->bindParam(':combinationUUID', $combinationUUID);
$lenght = count($product);
for ($i = 0; $i < $lenght; $i++) {
$prenoteDetails_uuid = UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING);
$UUID = $product[$i]->UUID;
$Quantity = $product[$i]->Quantity;
$Price = $product[$i]->Price;
$UnitID = $product[$i]->UnitID;
$serialID = $product[$i]->SerialID;
$barcode = $product[$i]->barcode;
$combinationID = $product[$i]->optionID;
$combinationUUID = $product[$i]->optionUUID;
$handle->execute();
}
}
示例4: Execute
public function Execute($db, $params)
{
if (!isset($params["OwnerID"], $params["Resource"], $params["Expiration"]) || !UUID::TryParse($params["OwnerID"], $this->OwnerID)) {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) {
$this->CapabilityID = UUID::Random();
}
$resource = $params["Resource"];
$expiration = intval($params["Expiration"]);
// Sanity check the expiration date
if ($expiration <= time()) {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid expiration date ' . $expiration . '" }';
exit;
}
log_message('debug', "Creating capability " . $this->CapabilityID . " owned by " . $this->OwnerID . " mapping to {$resource} until {$expiration}");
$sql = "INSERT INTO Capabilities (ID, OwnerID, Resource, ExpirationDate) VALUES (:ID, :OwnerID, :Resource, FROM_UNIXTIME(:ExpirationDate))\n ON DUPLICATE KEY UPDATE ID=VALUES(ID), Resource=VALUES(Resource), ExpirationDate=VALUES(ExpirationDate)";
$sth = $db->prepare($sql);
if ($sth->execute(array(':ID' => $this->CapabilityID, ':OwnerID' => $this->OwnerID, ':Resource' => $resource, ':ExpirationDate' => $expiration))) {
header("Content-Type: application/json", true);
echo sprintf('{"Success": true, "CapabilityID": "%s"}', $this->CapabilityID);
exit;
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
}
示例5: Execute
public function Execute($db, $params)
{
if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
$sql = "SELECT OwnerID,Resource,UNIX_TIMESTAMP(ExpirationDate) AS ExpirationDate FROM Capabilities WHERE ID=:ID AND UNIX_TIMESTAMP(ExpirationDate) > UNIX_TIMESTAMP() LIMIT 1";
$sth = $db->prepare($sql);
if ($sth->execute(array(':ID' => $this->CapabilityID))) {
if ($sth->rowCount() > 0) {
$obj = $sth->fetchObject();
header("Content-Type: application/json", true);
echo sprintf('{"Success": true, "CapabilityID": "%s", "OwnerID": "%s", "Resource": "%s", "Expiration": %u}', $this->CapabilityID, $obj->OwnerID, $obj->Resource, $obj->ExpirationDate);
exit;
} else {
header("Content-Type: application/json", true);
echo '{ "Message": "Capability not found" }';
exit;
}
}
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
示例6: locateObject
public function locateObject($slug, $parent = null, $kind = null, $universe = null)
{
$query = array();
$query['limit'] = 1;
if ($parent !== false) {
$query['parent'] = $parent;
}
if ($kind !== null) {
$query['kind'] = $kind;
}
if ($universe !== null) {
$query['universe'] = $universe;
}
if (null !== ($uuid = UUID::isUUID($slug))) {
$query['uuid'] = $uuid;
} else {
if (strpos($slug, ':') !== false) {
$query['iri'] = $slug;
} else {
$query['tag'] = $slug;
}
}
$rs = $this->query($query);
foreach ($rs as $obj) {
return $obj;
}
return null;
}
示例7: post_createPet
public function post_createPet()
{
$this->data = Input::all();
if ($this->data["clase_mascota"] == "Mini pig") {
$this->data["raza"] = "Mini pig";
}
$certificados = "";
$vacunas = "";
if (is_array($this->data["certificado"])) {
foreach ($this->data["certificado"] as $key => $certificado) {
$certificados .= $certificado . ", ";
}
$this->data["certificado"] = $certificados;
} else {
$this->data["certificado"] = "No tiene";
}
if (is_array($this->data["vacunas_cuales"])) {
foreach ($this->data["vacunas_cuales"] as $key => $vacuna) {
$vacunas .= $vacuna . ", ";
}
$this->data["vacunas_cuales"] = $vacunas;
} else {
$this->data["vacunas_cuales"] = "No tiene";
}
//print_r($this->data);die;
//$this->data["raza"] = empty($this->data["perro"]) ? $this->data["gato"] : $this->data["perro"];
//list($mes, $dia, $anio) = preg_split('/\//', $this->data["fecha_nacimiento"]);
//$this->data["fecha_nacimiento"] = strtotime($dia."-".$mes."-".$anio);
$this->data["uuid"] = UUID::getUUID();
if ($this->connection->mSave($this->data)) {
return json_encode(array("message" => "Mascota creada", "type" => 201, "error" => 0, "uuid" => $this->data["uuid"]));
} else {
return json_encode(array("message" => "Error al crear mascota", "type" => 500, "error" => 1));
}
}
示例8: Execute
public function Execute($db, $params)
{
if (isset($params["Identifier"], $params["Credential"], $params["Type"], $params["UserID"]) && UUID::TryParse($params["UserID"], $this->UserID)) {
if (isset($params["Enabled"]) && $params["Enabled"] == False) {
$parameters = array(':Identifier' => $params["Identifier"], ':Credential' => $params["Credential"], ':Type' => $params["Type"], ':UserID' => $this->UserID);
$sql = "INSERT INTO Identities (Identifier, Credential, Type, UserID, Enabled)\n VALUES (:Identifier, :Credential, :Type, :UserID, False)\n ON DUPLICATE KEY UPDATE Credential=VALUES(Credential), Type=VALUES(Type), UserID=VALUES(UserID), Enabled=VALUES(Enabled)";
} else {
$parameters = array(':Identifier' => $params["Identifier"], ':Credential' => $params["Credential"], ':Type' => $params["Type"], ':UserID' => $this->UserID);
$sql = "INSERT INTO Identities (Identifier, Credential, Type, UserID)\n VALUES (:Identifier, :Credential, :Type, :UserID)\n ON DUPLICATE KEY UPDATE Credential=VALUES(Credential), Type=VALUES(Type), UserID=VALUES(UserID), Enabled=1";
}
$sth = $db->prepare($sql);
if ($sth->execute($parameters)) {
header("Content-Type: application/json", true);
echo '{ "Success": true }';
exit;
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
} else {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
}
示例9: tweet_post
function tweet_post()
{
$args = func_get_args();
$cate = $args[2];
$content = format_str($_POST['text'], false);
if (!$cate or !$content) {
die("Invalid argument!");
}
include_once 'sinaoauth.inc.php';
$c = new WeiboClient(SINA_AKEY, SINA_SKEY, $GLOBALS['user']['sinakey']['oauth_token'], $GLOBALS['user']['sinakey']['oauth_token_secret']);
if ($_FILES['upload']['tmp_name']) {
$msg = $c->upload($content, $_FILES['upload']['tmp_name']);
} else {
$msg = $c->update($content);
}
if ($msg === false || $msg === null) {
echo "Error occured";
return false;
}
if (isset($msg['error_code']) && isset($msg['error'])) {
echo 'Error_code: ' . $msg['error_code'] . '; Error: ' . $msg['error'];
return false;
}
include_once "uuid.inc.php";
$v4uuid = str_replace("-", "", UUID::v4());
connect_db();
$add = "INSERT INTO pending_tweets (\r\n site_id, tweet_id, user_site_id, content, post_datetime,\r\n type, tweet_site_id,\r\n post_screenname, profile_image_url, source)\r\n VALUES (1, '{$v4uuid}', '" . $msg['user']['id'] . "', '{$content}', '" . date("Y-m-d H:i:s", strtotime($msg["created_at"])) . "',\r\n {$cate}, '" . $msg['id'] . "', '" . $msg["user"]["name"] . "', '" . $msg["user"]["profile_image_url"] . "', '" . $msg["source"] . "')";
if ($msg['thumbnail_pic']) {
$add = "INSERT INTO pending_tweets (\r\n site_id, tweet_id, user_site_id, content, post_datetime,\r\n type, tweet_site_id,\r\n post_screenname, profile_image_url, source, thumbnail)\r\n VALUES (1, '{$v4uuid}', '" . $msg['user']['id'] . "', '{$content}', '" . date("Y-m-d H:i:s", strtotime($msg["created_at"])) . "',\r\n {$cate}, '" . $msg['id'] . "', '" . $msg["user"]["name"] . "', '" . $msg["user"]["profile_image_url"] . "', '" . $msg["source"] . "', '" . $msg['thumbnail_pic'] . "')";
}
$added = mysql_query($add) or die("Could not add entry!");
echo "0";
}
示例10: fromStorageRow
public static function fromStorageRow(array $row, $obj = null)
{
/** @var $obj AbstractSummary */
$obj = parent::fromStorageRow($row, $obj);
$obj->summaryTargetId = UUID::create($row['rev_type_id']);
return $obj;
}
示例11: assignCredentials
/**
* Update the sign-in credentials for the specific user.
*
* @param UserRecord $user The user to update the credentials for
* @return Boolean True on success
*/
public function assignCredentials(UserRecord $user)
{
$db = new DatabaseConnection();
// Generate a new salt and hash the password
$salt = $this->generateSalt();
// What hashing algorithm to use
$ha = config::get('lepton.user.hashalgorithm', 'md5');
$ps = $user->password . $salt;
$hp = hash($ha, $ps);
if ($user->userid == null) {
$uuid = UUID::v4();
try {
$id = $db->insertRow("REPLACE INTO " . LEPTON_DB_PREFIX . "users (username,salt,password,email,flags,registered,uuid) VALUES (%s,%s,%s,%s,%s,NOW(),%s)", $user->username, $salt, $hp, $user->email, $user->flags, $uuid);
$user->userid = $id;
} catch (Exception $e) {
throw $e;
// TODO: Handle exception
}
} else {
try {
$db->updateRow("UPDATE " . LEPTON_DB_PREFIX . "users SET username=%s,salt=%s,password=%s,email=%s,flags=%s WHERE id=%d", $user->username, $salt, $hp, $user->email, $user->flags, $user->userid);
} catch (Exception $e) {
throw $e;
// TODO: Handle exception
}
}
return true;
}
示例12: EditEntity
public function EditEntity($bo)
{
$db = new Database();
$newID = UUID::newID();
$ID = str_replace("sys", "", $bo["EntityName"]) . "id";
if ($bo[$ID] != null) {
$values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo);
$sql = 'UPDATE ' . $bo["EntityName"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"';
} else {
//
$fields = str_replace($ID . ",", "", $bo["EntityFields"]);
$values = SqlHelper::GetValues(explode(",", $fields), $bo);
$sql = 'INSERT INTO ' . $bo["EntityName"] . '(' . $ID . ',' . $fields . ')' . ' VALUES("' . $newID . '",' . $values . ')';
//table
if ($bo["EntityName"] == 'sysentity') {
$table = ';CREATE TABLE IF NOT EXISTS ' . $bo["Name"] . '(' . $bo["Name"] . 'ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' . $bo["Name"] . 'ID))ENGINE = InnoDB';
$sql .= $table;
}
if ($bo["EntityName"] == 'sysproperty') {
$result = $db->RunSQL('SELECT Name FROM SysEntity WHERE EntityID = ' . $bo["EntityID"]);
$table = ';ALTER TABLE ' . $result[0]['Name'] . ' ADD COLUMN ' . $bo["Name"] . ' VARCHAR(45) NULL ';
$sql .= $table;
}
}
$result = $db->ExecuteSQL($sql);
return $this->GetEntityView($bo["RefreshEntityViewID"], array("id" => $newID));
}
示例13: Execute
public function Execute($db, $params)
{
$sql = "SELECT Identifier, Type, Credential, UserID, Enabled FROM Identities WHERE";
$id = null;
if (isset($params["UserID"]) && UUID::TryParse($params["UserID"], $id)) {
$sql .= " UserID=:ID";
} else {
if (isset($params["Identifier"])) {
$id = $params["Identifier"];
$sql .= " Identifier=:ID";
} else {
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
}
$sth = $db->prepare($sql);
if ($sth->execute(array(':ID' => $id))) {
$found = array();
while ($obj = $sth->fetchObject()) {
$found[] = sprintf('{"Identifier":"%s","Credential":"%s","Type":"%s","UserID":"%s","Enabled":%s}', $obj->Identifier, $obj->Credential, $obj->Type, $obj->UserID, $obj->Enabled ? 'true' : 'false');
}
header("Content-Type: application/json", true);
echo '{"Success":true,"Identities":[' . implode(',', $found) . ']}';
exit;
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
}
示例14: Execute
public function Execute($db, $params)
{
$asset = null;
$assetID = null;
if (isset($params["ID"]) && UUID::TryParse($params["ID"], $assetID)) {
log_message('debug', "xGetAsset asset: {$assetID}");
$assets = new SQLAssets($db);
$asset = $assets->GetAsset($assetID);
}
$response = array();
if (!empty($asset)) {
$response['Success'] = TRUE;
$response['SHA256'] = $asset->SHA256;
$response['Last-Modified'] = gmdate(DATE_RFC850, $asset->CreationDate);
$response['CreatorID'] = $asset->CreatorID;
$response['ContentType'] = $asset->ContentType;
$response['ContentLength'] = $asset->ContentLength;
$response['EncodedData'] = base64_encode($asset->Data);
$response['Temporary'] = $asset->Temporary;
} else {
log_message('info', "Asset {$assetID} not found");
$response['Success'] = FALSE;
$response['Message'] = "Asset {$assetID} not found";
}
header("Content-Type: application/json", true);
echo json_encode($response);
exit;
}
示例15: Execute
public function Execute($db, $params)
{
if (isset($params["SceneID"], $params["Enabled"]) && UUID::TryParse($params["SceneID"], $this->SceneID)) {
$sql = "UPDATE Scenes SET Enabled=:Enabled WHERE ID='" . $this->SceneID . "'";
} else {
if (isset($params["Name"], $params["Enabled"])) {
$sql = "UPDATE Scenes SET Enabled=:Enabled WHERE Name='" . $params["Name"] . "'";
} else {
log_message('error', sprintf("AddScene: Unable to parse passed parameters or parameter missing: '%s'", print_r($params, true)));
header("Content-Type: application/json", true);
echo '{ "Message": "Invalid parameters" }';
exit;
}
}
$sth = $db->prepare($sql);
if ($sth->execute(array(':Enabled' => $params["Enabled"]))) {
if ($sth->rowCount() > 0) {
header("Content-Type: application/json", true);
echo '{ "Success": true }';
exit;
} else {
log_message('error', "Failed updating the database");
header("Content-Type: application/json", true);
echo '{ "Message": "Database update failed" }';
exit;
}
} else {
log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true)));
log_message('debug', sprintf("Query: %s", $sql));
header("Content-Type: application/json", true);
echo '{ "Message": "Database query error" }';
exit;
}
}