日期:2014-05-16 浏览次数:20430 次
下面是sql和Mongodb对应的一些语法:
SQL Statement | Mongo Query Language Statement |
---|---|
CREATE TABLE USERS (a Number, b Number) | Implicit or use MongoDB::createCollection(). |
INSERT INTO USERS VALUES(1,1) | $db->users->insert(array("a" => 1, "b" => 1)); |
SELECT a,b FROM users | $db->users->find(array(), array("a" => 1, "b" => 1)); |
SELECT * FROM users WHERE age=33 | $db->users->find(array("age" => 33)); |
SELECT a,b FROM users WHERE age=33 | $db->users->find(array("age" => 33), array("a" => 1, "b" => 1)); |
SELECT a,b FROM users WHERE age=33 | $db->users->find(array("age" => 33), array("a" => 1, "b" => 1)); |
SELECT a,b FROM users WHERE age=33 ORDER BY name | $db->users->find(array("age" => 33), array("a" => 1, "b" => 1))->sort(array("name" => 1)); |
SELECT * FROM users W
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|