本文整理汇总了PHP中DB::Run方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::Run方法的具体用法?PHP DB::Run怎么用?PHP DB::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
public function Delete()
{
if (!$this->ID) {
return false;
}
$q = "DELETE FROM SurveyAnswers WHERE ID='{$this->ID}' LIMIT 1";
return DB::Run($q);
}
示例2: Revoke
private function Revoke($objectID, $objectType)
{
if ($objectType != "Member" && $objectType != "Calling" || !$objectID || !$this->ID) {
return false;
}
$q = "DELETE FROM GrantedPrivileges WHERE PrivilegeID='{$this->ID}' AND {$objectType}ID='{$objectID}' LIMIT 1";
if (!DB::Run($q)) {
die("ERROR > Could not revoke that privilege... sorry! " . mysql_error());
}
return true;
}
示例3: Save
public function Save()
{
// Can we have multiple answer options of the exact
// same value for the same question?
// Right now... NO.
// Make safe the answer value before our preliminary query (including stripping HTML tags)
$safeAns = DB::Safe($this->AnswerValue);
$q = "SELECT 1 FROM SurveyAnswerOptions WHERE QuestionID='{$this->QuestionID}' AND AnswerValue='{$safeAns}' LIMIT 1";
if (mysql_num_rows(DB::Run($q)) > 0) {
fail("Hmmm, this answer option ({$this->AnswerValue}) already exists for this question. Are you sure you didn't mean something else?");
}
$q = DB::BuildSaveQuery($this, get_object_vars($this));
$r = DB::Run($q);
if (!$this->ID) {
$this->ID = mysql_insert_id();
}
return $r ? true : false;
}
示例4: Save
public function Save()
{
if (!$this->GroupName || !$this->WardID) {
return false;
}
if (!$this->ID) {
$this->ID = 0;
}
// Pascal-case the FHE group name for consistency
$this->GroupName = ucwords(strtolower(trim($this->GroupName)));
// Sanitize the name before we use it in our query below...
$safeName = DB::Safe($this->GroupName);
// Make sure the group title is unique
$q = "SELECT 1 FROM FheGroups WHERE GroupName='{$safeName}' AND ID!='{$this->ID}' LIMIT 1";
if (mysql_num_rows(DB::Run($q)) > 0) {
fail("Oops. Could not save the FHE group; the name is already the name of another group, and they must be unique.");
}
$q = DB::BuildSaveQuery($this, get_object_vars($this));
$r = DB::Run($q);
if (!$this->ID) {
$this->ID = mysql_insert_id();
}
return $r ? true : false;
}
示例5: Save
public function Save()
{
if (!$this->Name) {
return false;
}
if (!$this->ID) {
$this->ID = 0;
}
$this->Name = str_ireplace("stake", "", $this->Name);
$this->Name = trim(strip_tags($this->Name));
// Sanitize the name before we use it in our query below...
$safeName = DB::Safe($this->Name);
// Make sure the calling title is unique
$q = "SELECT 1 FROM Stakes WHERE Name='{$safeName}' AND ID!='{$this->ID}' LIMIT 1";
if (mysql_num_rows(DB::Run($q)) > 0) {
fail("Oops. Could not save Stake information; the name of the stake already exists.");
}
$q = DB::BuildSaveQuery($this, get_object_vars($this));
$r = DB::Run($q);
if (!$this->ID) {
$this->ID = mysql_insert_id();
}
return $r ? true : false;
}
示例6: fail
exit;
}
@($yyyy = $_POST['year']);
@($mm = $_POST['month']);
@($dd = $_POST['day']);
if (!$yyyy || !$mm || !$dd || $yyyy < 2011 || $yyyy > date("Y") || $mm < 1 || $mm > 12 || $dd < 1 || $dd > 31 || !is_numeric($yyyy) || !is_numeric($mm) || !is_numeric($dd)) {
fail("Please be sure to select a cutoff date: day, month, and year.");
}
// The filename of the to-be-downloaded file. Make safe and strip out common words
$safeName = str_replace(" ", "_", strtolower($WARD->Name));
$safeName = preg_replace("/[^0-9A-Za-z_]+/", "", $safeName);
$safeName = preg_replace("/provo|utah|ysa|logan|ogden|orem|alpine|salt_lake_city|slc|salt_lake/", "", $safeName);
$safeName = trim($safeName, "_- ");
$filename = "{$safeName}_mls.csv";
// Run query; prepare to use results
$q = DB::Run("SELECT ID FROM Members WHERE WardID='{$WARD->ID()}' AND RegistrationDate >= '{$yyyy}-{$mm}-{$dd}' ORDER BY RegistrationDate ASC");
// Prepare the csv file
$csv = new CSVBuilder();
// Fields for the header of the file
$csv->AddField("Name");
$csv->AddField("Birth Date");
$csv->AddField("Address");
$csv->AddField("City");
$csv->AddField("State");
$csv->AddField("Postal");
$csv->AddField("Phone");
$csv->AddField("Prior Unit");
// Add all the data to the file
while ($r = mysql_fetch_array($q)) {
$m = Member::Load($r['ID']);
$res = $m->Residence();
示例7: Delete
public function Delete($sure = false)
{
// Safety
if ($sure !== true || !$this->ID) {
return false;
}
// Delete any password reset tokens
$q = "DELETE FROM PwdResetTokens WHERE CredentialsID='{$this->CredentialsID}'";
if (!DB::Run($q)) {
fail("Could not delete password reset tokens: " . mysql_error());
}
// Delete credentials
$q = "DELETE FROM Credentials WHERE ID='{$this->CredentialsID}'";
if (!DB::Run($q)) {
fail("Deleted password reset tokens but not anything else (stake leader can still login): " . mysql_error());
}
// Delete stake leader record
$q = "DELETE FROM StakeLeaders WHERE ID='{$this->ID}' LIMIT 1";
if (!DB::Run($q)) {
fail("Deleted password reset tokens and credentials but not account (stake leader CANNOT login, but record still exists!), problem - " . mysql_error());
}
return true;
}
示例8: elseif
?>
<?php
if ($MEMBER->HasPrivilege(PRIV_DELETE_ACCTS)) {
?>
<a href="/manage/prune">Delete Accounts</a><?php
}
}
?>
<?php
} elseif ($MEMBER == null && $LEADER != null) {
?>
<b>Wards</b>
<?php
// Show list of other wards they can view
$wardsQuery = DB::Run("SELECT Name, ID FROM Wards WHERE StakeID='{$LEADER->StakeID}' AND Deleted != 1 ORDER BY Name ASC");
while ($wardRow = mysql_fetch_array($wardsQuery)) {
?>
<a href="/api/changeward?id=<?php
echo $wardRow['ID'];
?>
"><i class="fa fa-asterisk"></i><?php
echo $wardRow['Name'];
?>
</a></li>
<?php
}
?>
<b>Membership</b>
<a href="/directory?stake"><i class="fa fa-list-alt"></i>Stake Directory</a>
示例9: DeleteWardItems
private function DeleteWardItems()
{
// Delete calling assignments
$q = "DELETE FROM MembersCallings WHERE MemberID='{$this->ID}'";
if (!DB::Run($q)) {
fail("Tried to delete member ID {$this->ID}'s calling assignments, but failed: " . mysql_error());
}
// Delete permissions for this MEMBER (not his/her calling)
$q = "DELETE FROM Permissions WHERE ObjectType='Member' AND ObjectID='{$this->ID}'";
if (!DB::Run($q)) {
fail("Deleted calling assignments for this member, but could not delete permissions. MySQL error: " . mysql_error());
}
// Delete privileges for this MEMBER (not his/her calling)
$q = "DELETE FROM GrantedPrivileges WHERE MemberID='{$this->ID}'";
if (!DB::Run($q)) {
fail("Deleted calling assignments, and permissions for this member, but could not delete granted privileges. MySQL error: " . mysql_error());
}
// Delete any password reset tokens
$q = "DELETE FROM PwdResetTokens WHERE CredentialsID='{$this->CredentialsID}'";
if (!DB::Run($q)) {
fail("Deleted this member's calling assignments, privileges, and permissions, but not password reset tokens: " . mysql_error());
}
// Delete survey answers
$q = "DELETE FROM SurveyAnswers WHERE MemberID='{$this->ID}'";
if (!DB::Run($q)) {
fail("Deleted permissions, callings, privileges, and password reset tokens, but not survey answers. Problem was: " . mysql_error());
}
// Delete custom Residence, if any
if ($this->HasCustomResidence()) {
$q = "DELETE FROM Residences WHERE ID='{$this->ResidenceID}' AND Custom=1";
if (!DB::Run($q)) {
fail("Deleted permissions, callings, privileges, password reset tokens, survey answers, and credentials, but not Residence: " . mysql_error());
}
}
}
示例10: Members
public function Members()
{
$q = "SELECT `MemberID` FROM `MembersCallings` WHERE `CallingID`={$this->ID}";
$r = DB::Run($q);
$members = array();
while ($row = mysql_fetch_array($r)) {
$members[] = Member::Load($row['MemberID']);
}
return $members;
}
示例11:
@($ldr1 = $_POST['ldr1']);
@($ldr2 = $_POST['ldr2']);
@($ldr3 = $_POST['ldr3']);
if (!$name) {
Response::Send(400, "Please type a group name.");
}
// Make sure new leaders are removed from old group leaderships.
// This next for loop is the exact same as the loop above near the top of this file.
// TODO: This setup is awful. I want to redo this another time. What if the
// leadership becomes discombobulated? (e.g. removes a leader1 but keeps leader 2... just looks weird)
// This is a messy implementation. That's what I get for being in a hurry, I guess.
//DB::Run("UPDATE FheGroups SET Leader1=0 WHERE Leader1='$ldr1' OR Leader1='$ldr2' OR Leader1='$ldr3'");
//DB::Run("UPDATE FheGroups SET Leader2=0 WHERE Leader2='$ldr1' OR Leader2='$ldr2' OR Leader2='$ldr3'");
//DB::Run("UPDATE FheGroups SET Leader3=0 WHERE Leader3='$ldr1' OR Leader3='$ldr2' OR Leader3='$ldr3'");
for ($i = 1; $i <= 3; $i++) {
DB::Run("UPDATE FheGroups SET Leader{$i}=0 WHERE Leader{$i}='{$ldr1}' OR Leader{$i}='{$ldr2}' OR Leader{$i}='{$ldr3}'");
}
// Make assignments, but don't save changes yet.
$group->GroupName = $_POST['groupname'];
$group->Leader1 = $_POST['ldr1'];
$group->Leader2 = $_POST['ldr2'];
$group->Leader3 = $_POST['ldr3'];
// Move the leaders into their new groups
if ($group->Leader1 > 0) {
$mem = Member::Load($group->Leader1);
$mem->FheGroup = $id;
$mem->Save();
}
if ($group->Leader2 > 0) {
$mem = Member::Load($group->Leader2);
$mem->FheGroup = $id;
示例12: Delete
public function Delete($sure = false)
{
if ($sure !== true) {
fail("Could not delete this question; pass in boolean true to be sure.");
}
if (!$this->ID) {
fail("Could not delete this question, because no valid ID was associated with it.");
}
// "Make safe the harbor!" ... or ... "Make safe the city!" (pick your movie; I prefer the latter)
$safeID = DB::Safe($this->ID);
// Delete all SurveyAnswerOptions to it
$this->DeleteAllAnswerOptions(true);
// Delete all permissions for it
$q = "DELETE FROM Permissions WHERE QuestionID='{$safeID}'";
if (!DB::Run($q)) {
fail("Could not delete permissions for this question with ID {$this->ID}, reason: " . mysql_error());
}
// Delete all answers to this question
foreach ($this->Answers() as $ans) {
$ans->Delete();
}
// Delete the question, at last.
$q = "DELETE FROM SurveyQuestions WHERE ID='{$safeID}' LIMIT 1";
if (!DB::Run($q)) {
fail("Could not delete question with ID {$this->ID} from database (but answers, answer options, and permissions for it were all deleted), reason: " . mysql_error());
}
return true;
}
示例13:
<br>
<input type="submit" value="Grant to Calling" class="button sm">
</form>
<br>
<h2 id="by-calling">Privileges granted to callings</h2>
<table class="privList">
<tr>
<th>Calling</th>
<th>Privilege</th>
<th>Options</th>
</tr>
<?php
$rm = DB::Run("SELECT CallingID, PrivilegeID FROM GrantedPrivileges INNER JOIN Callings ON Callings.ID = CallingID INNER JOIN Privileges ON Privileges.ID = GrantedPrivileges.PrivilegeID WHERE CallingID > 0 AND Callings.WardID={$MEMBER->WardID} ORDER BY Callings.Name ASC, Privileges.Privilege ASC");
while ($row = mysql_fetch_array($rm)) {
$priv = Privilege::Load($row['PrivilegeID']);
$call = Calling::Load($row['CallingID']);
?>
<tr>
<td>
<b><?php
echo $call->Name;
?>
</b>
</td>
<td>
<span title="<?php
echo $priv->HelpText();
?>
示例14: trim
<?php
require_once "../lib/init.php";
@($eml = trim($_POST['eml']));
@($pwd = trim($_POST['pwd']));
// Login; returns null if bad credentials.
// First see if they're a regular member...
$m = Member::Login($eml, $pwd);
// Where to potentially redirect the member after login
$afterLogin = isset($_SESSION['after_login']) ? $_SESSION['after_login'] : "/directory";
if (!$m) {
// No? Maybe a stake leader?
$s = StakeLeader::Login($eml, $pwd);
if (!$s) {
Response::Send(400);
} else {
// Choose the first ward in the stake... alphabetically I guess... as default view for them.
$r = mysql_fetch_array(DB::Run("SELECT ID FROM Wards WHERE StakeID='{$s->StakeID}' AND Deleted != 1 ORDER BY Name ASC LIMIT 1"));
$_SESSION['wardID'] = $r['ID'];
// Stake leader logged in.
Response::Send(200, $afterLogin);
}
} else {
Response::Send(200, $afterLogin);
}
示例15:
if ($pwd1 != $pwd2) {
Response::Send(400, "Your passwords don't match. Make sure they match.");
}
// Check length
if (strlen($pwd1) < 8) {
Response::Send(400, "Your password is too short. Please make it at least 8 characters.");
}
// Verify that the credentials ID matches the token
$credID = DB::Safe($credID);
$token = DB::Safe($token);
$r = DB::Run("SELECT 1 FROM `PwdResetTokens` WHERE `CredentialsID`='{$credID}' AND `Token`='{$token}' LIMIT 1");
if (mysql_num_rows($r) == 0) {
Response::Send(400, "Account ID and token do not appear to match. Maybe try again from the link in your email?");
}
// Get account object (Member or Leader) -- first we have to determine which type it is
$q2 = DB::Run("SELECT * FROM Credentials WHERE ID='{$credID}' LIMIT 1");
$r = mysql_fetch_array($q2);
$memberID = $r['MemberID'];
$leaderID = $r['StakeLeaderID'];
$user = null;
if ($memberID && !$leaderID) {
$user = @Member::Load($memberID);
} else {
if ($leaderID && !$memberID) {
$user = @StakeLeader::Load($leaderID);
}
}
if (!$user) {
Response::Send(500, "Could not load account with ID '{$memberID}' or '{$leaderID}', from credentials ID {$credID} -- please report this exact error message. Thanks...");
}
// Reset password.