Created
July 20, 2012 18:02
-
-
Save darkredz/3152294 to your computer and use it in GitHub Desktop.
Using MongoRegex vs Javascript Expression $where
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //With proper Indexing this will be a lot faster than JS Expression | |
| $categoryInput = strtolower($postedFromSomeWhere); | |
| $categoryInput = preg_quote($categoryInput); | |
| $regex = new MongoRegex ('/^'. $categoryInput .'$/i'); | |
| $categoryModel = new Category; | |
| $rs = $categoryModel->findOne( | |
| 'username' => 'leng', | |
| 'category' => $regex, | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment