本文整理汇总了PHP中Query::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::delete方法的具体用法?PHP Query::delete怎么用?PHP Query::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleting
function deleting($table, $where)
{
$q = new Query();
$q->table = $table;
$q->where = $where;
$q->delete();
}
示例2: delete
static function delete($id)
{
$tname = static::tableName();
$query = new Query($tname);
$pk = static::$primaryKey;
$query->delete($tname)->where("`{$tname}`.`{$pk}` = ?", [$id]);
static::query($query, $query->params);
}
示例3: delete
/**
* Delete a model from the database.
*
* @param int $id
* @return int
*/
public function delete($id = null)
{
// If the delete method is being called on an existing model, we only want to delete
// that model. If it is being called from an Eloquent query model, it is probably
// the developer's intention to delete more than one model, so we will pass the
// delete statement to the query instance.
if (!$this->exists) {
return $this->query->delete();
}
return DB::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
}
示例4: removeRelation
protected function removeRelation($object)
{
if (!isset($this->owner)) {
return false;
}
// can't add without
$owner = $this->owner;
$joint = static::tableJoin($owner->tableName, $object->tableName);
// get the joint table
$query = new Query($joint);
$query->delete($joint)->where("{$object->tableName} = ? AND {$owner->tableName} = ?", [$object->primaryKey, $owner->primaryKey]);
static::query($query, $query->params);
}
示例5: process
public function process($get, $post)
{
if (!isset($post['course_id']) || !is_numeric($post['course_id']) || !isset($_COOKIE['sessionId']) || !is_numeric($_COOKIE['sessionId'])) {
$this->failureReason = 'Sorry, there was an error.';
return false;
}
$query = new Query('action');
// Select all the courses that are in this user's session and have this course id
$result = $query->delete(array(array('course_id', '=', $post['course_id']), array('session_id', '=', $_COOKIE['sessionId'])));
if (!$result) {
// Abort because this course is already in the user's model
$this->failureReason = 'Sorry, there was an error.';
return false;
}
return true;
}
示例6: delSoporte
public function delSoporte($soporte)
{
return $this->_query->delete($soporte);
}
示例7: Query
<?php
include "sources/funciones.php";
if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_GET) {
$id = $_GET['id'];
require "sources/Query.inc";
$query = new Query();
if ($query->delete("dependencia", "idDependencia={$id}")) {
$respuesta = '
<img src="images/ok.png" width="100">
<h4>
Dependencia eliminada correctamente.
</h4>
';
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error.
</h4>
';
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include 'sources/template/head.php';
?>
<meta http-equiv="Refresh" content="2;url=consultarDependencia.php" />
</head>
示例8: delete
/**
* Create delete query
*
* @param string $table
* @param string $handler
* @return mixed
*/
public static function delete($table, $handler = null)
{
return Query::delete($table, $handler);
}
示例9: Query
<?php
include "sources/funciones.php";
if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_GET) {
$id = $_GET['id'];
require "sources/Query.inc";
$query = new Query();
if ($query->delete("redaccion", "idRedaccion={$id}")) {
$respuesta = '
<img src="images/ok.png" width="100">
<h4>
Saludo eliminado correctamente.
</h4>
';
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error.
</h4>
';
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include 'sources/template/head.php';
?>
<meta http-equiv="Refresh" content="2;url=consultarRedaccion.php" />
</head>
示例10: Status
addButton('btn btn-success', 'Submit', 'col-sm-offset-2 col-sm-4', 'Sign Up');
?>
</fieldset>
</form>
<?php
require_once 'Status.php';
require_once 'database.php';
$q = new Status($db);
$q->viewStatus('dvd', 'available', 'Return');
?>
<?php
require_once "Query.php";
$crud_book = new Query(7, 'dvd', 'item_no,title,genre,description,price,rental_period,status');
$crud_book->mysqlConnect('localhost', 'root', '', 'video_rental');
$crud_book->create();
echo "<hr/>";
$crud_book->read();
echo "<hr/>";
$crud_book->update();
echo "<hr/>";
$crud_book->delete();
echo "<hr/>";
?>
</div>
</div>
</div>
</body>
</html>
示例11: dumpTable
/**
* Метод выполняет дамп таблицы
*/
public static function dumpTable($idColumn, $table, array $where = array(), $order = null)
{
//Стартуем секундомер
$secundomer = Secundomer::startedInst("Снятие дампа {$table}");
//Отключим ограничение по времени
PsUtil::startUnlimitedMode();
//Получим экземпляр логгера
$LOGGER = PsLogger::inst(__CLASS__);
//Текущий пользователь
$userId = AuthManager::getUserIdOrNull();
//Для логов, запросов и все остального
$table = strtoupper(PsCheck::tableName($table));
//Макс кол-во записей
$limit = PsDefines::getTableDumpPortion();
//Проверим наличие id
$idColumn = PsCheck::tableColName($idColumn);
$LOGGER->info('Dumping table {}. Id column: {}, limit: {}. User id: {}.', $table, $idColumn, $limit, $userId);
//Получаем лок (без ожидания)
$lockName = "DUMP table {$table}";
$locked = PsLock::lock($lockName, false);
$LOGGER->info('Lock name: {}, locked ? {}.', $lockName, var_export($locked, true));
if (!$locked) {
return false;
//Не удалось получить лок
}
$zipDi = false;
try {
//ЗПРОСЫ:
//1. Запрос на извлечение колва записей, подлежащих дампированию
$queryCnt = Query::select("count({$idColumn}) as cnt", $table, $where);
//2. Запрос на извлечение данных, подлежащих дампированию
$queryDump = Query::select('*', $table, $where, null, $order, $limit);
//3. Запрос на извлечение кодов дампируемых записей
$selectIds = Query::select($idColumn, $table, $where, null, $order, $limit);
//4. Запрос на удаление дампированных данных
$queryDel = Query::delete($table, Query::plainParam("{$idColumn} in (select {$idColumn} from (" . $selectIds->build($delParams) . ') t )', $delParams));
//Выполним запрос для получения кол-ва записей, подлежащих дампу
$cnt = PsCheck::int(array_get_value('cnt', PSDB::getRec($queryCnt, null, true)));
$LOGGER->info('Dump recs count allowed: {}.', $cnt);
if ($cnt < $limit) {
$LOGGER->info('SKIP dumping table, count allowed ({}) < limit ({})...', $cnt, $limit);
$LOGGER->info("Query for extract dump records count: {$queryCnt}");
PsLock::unlock($lockName);
return false;
}
//Время дампа
$date = PsUtil::fileUniqueTime(false);
$time = time();
//Название файлов
$zipName = $date . ' ' . $table;
//Элемент, указывающий на zip архив
$zipDi = DirManager::stuff(null, array(self::DUMPS_TABLE, $table))->getDirItem(null, $zipName, PsConst::EXT_ZIP);
$LOGGER->info('Dump to: [{}].', $zipDi->getAbsPath());
if ($zipDi->isFile()) {
$LOGGER->info('Dump file exists, skip dumping table...');
PsLock::unlock($lockName);
return false;
}
//Комментарий к таблице
$commentToken[] = "Date: {$date}";
$commentToken[] = "Time: {$time}";
$commentToken[] = "Table: {$table}";
$commentToken[] = "Manager: {$userId}";
$commentToken[] = "Recs dumped: {$limit}";
$commentToken[] = "Total allowed: {$cnt}";
$commentToken[] = "Query dump cnt: {$queryCnt}";
$commentToken[] = "Query dump data: {$queryDump}";
$commentToken[] = "Query dump ids: {$selectIds}";
$commentToken[] = "Query del dumped: {$queryDel}";
$comment = implode("\n", $commentToken);
//Начинаем zip и сохраняем в него данные
$zip = $zipDi->startZip();
$zip->addFromString($zipName, serialize(PSDB::getArray($queryDump)));
$zip->setArchiveComment($comment);
$zip->close();
$LOGGER->info('Data successfully dumped, zip comment:');
$LOGGER->info("[\n{$comment}\n]");
//Удалим те записи, дамп которых был снят
$LOGGER->info('Clearing dumped table records...');
$affected = PSDB::update($queryDel);
$LOGGER->info('Rows deleted: {}.', $affected);
$LOGGER->info('Dumping is SUCCESSFULLY finished. Total time: {} sec.', $secundomer->stop()->getAverage());
} catch (Exception $ex) {
PsLock::unlock($lockName);
ExceptionHandler::dumpError($ex);
$LOGGER->info('Error occured: {}', $ex->getMessage());
throw $ex;
}
return $zipDi;
}
示例12: removeResetTokensOfUser
public function removeResetTokensOfUser($userId)
{
return Query::delete($this->getDomain()->getTableName(), "userId = :userId", array("userId" => $userId), 100);
}
示例13: deleteCommentsFor
public function deleteCommentsFor($id, $type)
{
$id = (int) $id;
$type = (string) $type;
Query::delete('comments')->where('record', $id)->andWhere('type', $type)->act();
}
示例14: delete
public static function delete($name)
{
list($id, $keys) = self::parseName($name);
// deleting (locally)
if (empty($keys)) {
unset(self::$fields[$id]);
} else {
self::deleteSubKey(self::$fields[$id], $keys);
}
// pushing changes to database
if (!array_key_exists($id, self::$fields)) {
// deleting field completely
Query::delete('config')->where('name', $id)->act();
self::$noSuchField[$id] = true;
} else {
// or only updating
Query::update('config')->where('name', $id)->set('value', serialize(self::$fields[$id]))->act();
}
}
示例15: Query
<?php
include "sources/funciones.php";
if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_GET) {
$id = $_GET['id'];
require "sources/Query.inc";
$query = new Query();
if ($query->delete("login", "idLogin={$id}")) {
$respuesta = '
<img src="images/ok.png" width="100">
<h4>
Usuario eliminado correctamente.
</h4>
';
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error.
</h4>
';
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include 'sources/template/head.php';
?>
<meta http-equiv="Refresh" content="2;url=consultarUsuario.php" />
</head>