当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiBase::sanitizeBit1diff方法代码示例

本文整理汇总了PHP中ApiBase::sanitizeBit1diff方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::sanitizeBit1diff方法的具体用法?PHP ApiBase::sanitizeBit1diff怎么用?PHP ApiBase::sanitizeBit1diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiBase的用法示例。


在下文中一共展示了ApiBase::sanitizeBit1diff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getChanges

 private function getChanges($limit, $offset, $constraints)
 {
     #list of columns available in the audit_table
     $cols = array('id', 'title', 'artist', 'descr', 'year', 'year_cmt', 'type', 'material', 'inside', 'address', 'county', 'muni', 'district', 'lat', 'lon', 'source', 'official_url', 'owner', 'cmt', 'created');
     #prepare sql statement
     $mainCols = '`main_table`.`' . implode(', `main_table`.`', array_map('self::colAsmPrefix', $cols));
     $auditCols = '`audit_table`.`' . implode(', `audit_table`.`', array_map('self::colAsaPrefix', $cols));
     $query = '
             SELECT SQL_CALC_FOUND_ROWS ' . $mainCols . ', ' . $auditCols . '
             FROM `main_table`, `audit_table`
             WHERE `main_table`.`ugc` = 1
             AND `main_table`.`id` = `audit_table`.`id`
             ';
     $query = isset($constraints) ? ApiBase::addConstraints($query . 'AND `main_table`.', $constraints, '`main_table`.') : $query;
     $query .= 'LIMIT ' . mysql_real_escape_string($offset) . ', ' . mysql_real_escape_string($limit) . '
             ';
     #run query
     $error = false;
     try {
         $response = ApiBase::doQuery($query);
         $hits = ApiBase::doQuery('SELECT FOUND_ROWS()');
     } catch (Exception $e) {
         throw $e;
         $error = true;
     }
     if (!$error) {
         #go through each row of response and compare audit to main
         $body = array();
         foreach ($response as $r) {
             $r = ApiBase::sanitizeBit1diff($r);
             $diff = array();
             $diff['id'] = $r['m_id'];
             foreach ($cols as $c) {
                 if ($r['m_' . $c] != $r['a_' . $c]) {
                     $diff[$c] = array('new' => $r['m_' . $c], 'old' => $r['a_' . $c]);
                 }
             }
             if (count($diff) > 1) {
                 #so as to remove any entries with only an id (i.e. only image added)
                 $body[] = array('diff' => $diff);
             }
         }
         return array($body, $hits);
     }
 }
开发者ID:Abbe98,项目名称:ODOK,代码行数:45,代码来源:ApiAdmin.php


注:本文中的ApiBase::sanitizeBit1diff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。