當前位置: 首頁>>代碼示例>>PHP>>正文


PHP dibi::delete方法代碼示例

本文整理匯總了PHP中dibi::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::delete方法的具體用法?PHP dibi::delete怎麽用?PHP dibi::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dibi的用法示例。


在下文中一共展示了dibi::delete方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateUserRoles

 /**
  * update user roles [delete & insert]
  *
  * @param int User id
  * @param int Role id
  */
 public function updateUserRoles($userId, $roles)
 {
     try {
         dibi::begin();
         dibi::delete(self::ACL_USERS_2_ROLES_TABLE)->where('user_id = %i', $userId)->execute();
         foreach ($roles as $role) {
             dibi::insert(self::ACL_USERS_2_ROLES_TABLE, array('user_id' => $userId, 'role_id' => $role))->execute();
         }
         dibi::commit();
     } catch (DibiDriverException $e) {
         dibi::rollback();
         throw $e;
     }
 }
開發者ID:radypala,項目名稱:maga-website,代碼行數:20,代碼來源:RolesModel.php

示例2: date_default_timezone_set

<h1>Using Fluent Syntax | dibi</h1>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
$id = 10;
$record = array('title' => 'Super product', 'price' => 318, 'active' => TRUE);
// SELECT ...
dibi::select('product_id')->as('id')->select('title')->from('products')->innerJoin('orders')->using('(product_id)')->innerJoin('customers USING (customer_id)')->orderBy('title')->test();
// -> SELECT [product_id] AS [id] , [title] FROM [products] INNER JOIN [orders]
//    USING (product_id) INNER JOIN customers USING (customer_id) ORDER BY [title]
// SELECT ...
echo dibi::select('title')->as('id')->from('products')->fetchSingle();
// -> Chair (as result of query: SELECT [title] AS [id] FROM [products])
// INSERT ...
dibi::insert('products', $record)->setFlag('IGNORE')->test();
// -> INSERT IGNORE INTO [products] ([title], [price], [active]) VALUES ('Super product', 318, 1)
// UPDATE ...
dibi::update('products', $record)->where('product_id = %d', $id)->test();
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
// DELETE ...
dibi::delete('products')->where('product_id = %d', $id)->test();
// -> DELETE FROM [products] WHERE product_id = 10
// custom commands
dibi::command()->update('products')->where('product_id = %d', $id)->set($record)->test();
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
dibi::command()->truncate('products')->test();
// -> TRUNCATE [products]
開發者ID:kravco,項目名稱:dibi,代碼行數:30,代碼來源:using-fluent-syntax.php

示例3: delete

 /**
  * basic delete specified by $id
  *
  * @param int $id
  * @param bool [optional] erase dir on filesystem?
  * @return DibiResult
  */
 public function delete($id)
 {
     if (func_num_args() > 1) {
         $rmDir = func_get_arg(1);
         if (!empty($rmDir)) {
             Basic::rmdir(static::PATH . $id, true);
         }
     }
     return dibi::delete(static::TABLE)->where('id=%i', $id)->execute();
 }
開發者ID:radypala,項目名稱:maga-website,代碼行數:17,代碼來源:BaseModel.php

示例4: deleteExpiredLoginTokens

 public function deleteExpiredLoginTokens()
 {
     dibi::delete(self::TEMPORARY_LOGIN_TABLE)->where('expire < NOW()')->execute();
 }
開發者ID:radypala,項目名稱:maga-website,代碼行數:4,代碼來源:UsersModel.php


注:本文中的dibi::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。