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


PHP DataManager::prepareConditions方法代碼示例

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


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

示例1: combineConditions

 /**
  * Get multiple conditions and combine them into one condition string
  * 
  * DataManager::combineConditions(array('project_id = ?', $project->getId()), 'is_visible = 1');
  * 
  * Will result in:
  * 
  * (project_id = '12') AND (is_visible = 1)
  * 
  * Empty conditions are ignored
  *
  * @param void
  * @return string
  */
 function combineConditions()
 {
     $args = func_get_args();
     if (!count($args)) {
         return '';
     }
     // if
     $conditions = array();
     foreach ($args as $arg) {
         $prepared = DataManager::prepareConditions($arg);
         if ($prepared) {
             $conditions[] = "({$prepared})";
         }
         // if
     }
     // foeach
     return count($conditions) ? implode(' AND ', $conditions) : '';
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:32,代碼來源:DataManager.class.php

示例2: delete

 /**
  * Delete records from attachments table that match given $conditions
  * 
  * This function also deletes all files from /upload folder so this function 
  * is not 100% transaction safe
  *
  * @param mixed $conditions
  * @return boolean
  */
 function delete($conditions = null)
 {
     $attachments_table = TABLE_PREFIX . 'attachments';
     $perpared_conditions = DataManager::prepareConditions($conditions);
     $where_string = trim($perpared_conditions) == '' ? '' : "WHERE {$perpared_conditions}";
     $rows = db_execute("SELECT id, location FROM {$attachments_table} {$where_string}");
     if (is_foreachable($rows)) {
         $attachments = array();
         foreach ($rows as $row) {
             if ($row['location']) {
                 $attachments[(int) $row['id']] = $row['location'];
             }
             // if
         }
         // foreach
         // Delete attachments
         $delete = db_execute("DELETE FROM {$attachments_table} WHERE id IN (?)", array_keys($attachments));
         if ($delete && !is_error($delete)) {
             foreach ($attachments as $location) {
                 @unlink(UPLOAD_PATH . '/' . $location);
             }
             // foreach
         }
         // if
         return $delete;
     }
     // if
     return true;
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:38,代碼來源:Attachments.class.php


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