public function group($keys, $initial, $reduce, $options = array()) { try { return $this->getCollection()->group($keys, $initial, $reduce, $options); } catch (MongoCursorException $e) { MyException::Exceptions($e->getMessage(), $e->getTrace()); } }
protected static function getFields($tabName) { $CacheFieldPos = $_SERVER['SINASRV_CACHE_DIR'] . '/DbFieldCache/'; $conn = self::achieveConn(TRUE); $filedPath = $CacheFieldPos . md5('Reluctance' . $tabName) . '.php'; try { $stmt = $conn->query('DESC ' . $tabName); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { MyException::Exceptions('您传入的表名不正确,请确认!<br />' . $e->getMessage(), $e->getTrace()); } if (DEBUG) { //本地环境 $fields = self::getFieldArray($result); if (file_exists($filedPath)) { //当修改数据库中字段重新生成新的文件 $fieldArr = (include $filedPath); if ($fieldArr == $fields) { return $fieldArr; } else { unlink($filedPath); } } } else { //线上环境,可以少一个foreach循环 if (file_exists($filedPath)) { return include $filedPath; } $fields = self::getFieldArray($result); } $tabName = md5('Reluctance' . $tabName); $FieldString = "<?php \n return " . var_export($fields, true) . ";\n?" . ">"; file_put_contents($CacheFieldPos . $tabName . '.php', $FieldString); return $fields; }