本文整理汇总了PHP中DBConnection::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::delete方法的具体用法?PHP DBConnection::delete怎么用?PHP DBConnection::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reconstruct
if (!empty($_POST['1'])) {
array_push($shares, $_POST['1']);
}
if (!empty($_POST['2'])) {
array_push($shares, $_POST['2']);
}
if (!empty($_POST['3'])) {
array_push($shares, $_POST['3']);
}
//var_dump($shares);
$reconstructed_secret = reconstruct($shares);
$db = new DBConnection();
$db->connect();
$user = get_user_info();
$secret = $db->query('secret', 'secret', "uid='{$user}'", null, null, null)[0]['secret'];
$db->delete('secret', "uid='{$user}'");
$db->disconnect();
if ($secret == $reconstructed_secret) {
echo "Secrets matching. Access granted.";
} else {
echo "{$secret} != {$reconstructed_secret}. Access denied";
}
} else {
echo "fail";
}
} else {
echo "fail";
}
/* [1,8683146895150534502] [2,17361141234745553751] [3,7143385603424603993]
* Secret 5152555555515253
*
示例2: array
echo '<p> All columns: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
echo '<p> Some columns: ';
var_dump($db->select('truck', array('brand', 'age'), 'id', $lastInsertedId));
echo '</p>';
/*
* SELECT ALL TEST.
*/
$db->insert('truck', array('brand' => 'Mercedes', 'age' => 3));
echo '<p> All rows and columns: ';
var_dump($db->select('truck', '*'));
/*
* UPDATE TEST.
*/
echo '<p> Before update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
$db->update('truck', array('vehicle_capacity' => 0, 'brand' => 'MAN', 'age' => 0), $lastInsertedId);
echo '<p> After update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
/*
* DELETE TEST.
*/
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId) . '</p>';
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId + 1) . '</p>';
/*
* GET TABLE COLUMNS NAMES TEST.
*/
var_dump($db->get_table_columns_names('truck'));
示例3: DBConnection
<?php
require_once "includes/db.class.inc";
require_once "includes/mailapi.inc";
require_once "includes/session.inc";
if (is_session_active()) {
$db = new DBConnection();
$db->connect();
$user = get_user_info();
$secretshare = $db->query('shares', 'share', "uid='{$user}' AND share LIKE '[2,%'", null, null, null)[0]['share'];
//print_r($secretshare);
$db->delete("shares", "share='{$secretshare}'");
$db->disconnect();
//send secretshare in sms
//sendsms($user, $share)
echo $secretshare;
//echo "fail";
//echo "success";
} else {
echo "fail";
}
示例4: delete
/**
* Delete selected instance of this type in the database.
* Returns the number of affected rows on success.
* @return int|null
*/
public function delete()
{
if ($this->id) {
$db = new DBConnection();
return $db->delete($this->convert_to_table_name($this->className), $this->id);
} else {
return null;
}
}