瀏覽代碼

Use internal function to generate index string

Andreas Braun 10 年之前
父節點
當前提交
8c4aef2b27
共有 1 個文件被更改,包括 1 次插入15 次删除
  1. 1 15
      lib/Mongo/MongoCollection.php

+ 1 - 15
lib/Mongo/MongoCollection.php

@@ -508,7 +508,7 @@ class MongoCollection
         if (is_string($keys)) {
             $indexName = $keys;
         } elseif (is_array($keys)) {
-            $indexName = self::toIndexString($keys);
+            $indexName = \MongoDB\generate_index_name($keys);
         } else {
             throw new \InvalidArgumentException();
         }
@@ -629,20 +629,6 @@ class MongoCollection
     }
 
     /**
-     * @param mixed $keys
-     * @static
-     * @return string
-     */
-    protected static function toIndexString($keys)
-    {
-        $result = '';
-        foreach ($keys as $name => $direction) {
-            $result .= sprintf('%s_%d', $name, $direction);
-        }
-        return $result;
-    }
-
-    /**
      * Performs an operation similar to SQL's GROUP BY command
      *
      * @link http://www.php.net/manual/en/mongocollection.group.php