当前位置: 首页>>代码示例>>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;未经允许,请勿转载。