moungoDB 语法

SQL查询语句    Mongo查询语句
CREATE TABLE USERS (a Number, b Number) 隐式的创建,或 MongoDB::createCollection().
INSERT INTO USERS VALUES(,) $db->users->insert(array("a" => , "b" => ));
SELECT a,b FROM users $db->users->find(array(), array("a" => , "b" => ));
SELECT * FROM users WHERE age= $db->users->find(array("age" => ));
SELECT a,b FROM users WHERE age= $db->users->find(array("age" => ), array("a" => , "b" => ));
SELECT a,b FROM users WHERE age= ORDER BY name $db->users->find(array("age" => ), array("a" => , "b" => ))->sort(array("name" => ));
SELECT * FROM users WHERE age> $db->users->find(array("age" => array('$gt' => )));
SELECT * FROM users WHERE age< $db->users->find(array("age" => array('$lt' => )));
SELECT * FROM users WHERE name LIKE "%Joe%" $db->users->find(array("name" => new MongoRegex("/Joe/")));
SELECT * FROM users WHERE name LIKE "Joe%" $db->users->find(array("name" => new MongoRegex("/^Joe/")));
SELECT * FROM users WHERE age> AND age<= $db->users->find(array("age" => array('$gt' => , '$lte' => )));
SELECT * FROM users ORDER BY name DESC $db->users->find()->sort(array("name" => -));
CREATE INDEX myindexname ON users(name) $db->users->ensureIndex(array("name" => ));
CREATE INDEX myindexname ON users(name,ts DESC) $db->users->ensureIndex(array("name" => , "ts" => -));
SELECT * FROM users WHERE a= and b='q' $db->users->find(array("a" => , "b" => "q"));
SELECT * FROM users LIMIT , $db->users->find()->limit()->skip();
SELECT * FROM users WHERE a= or b= $db->users->find(array('$or' => array(array("a" => ), array("b" => ))));
SELECT * FROM users LIMIT $db->users->find()->limit();
EXPLAIN SELECT * FROM users WHERE z= $db->users->find(array("z" => ))->explain()
SELECT DISTINCT last_name FROM users $db->command(array("distinct" => "users", "key" => "last_name"));
SELECT COUNT(*y) FROM users $db->users->count();
SELECT COUNT(*y) FROM users where AGE > $db->users->find(array("age" => array('$gt' => )))->count();
SELECT COUNT(AGE) from users $db->users->find(array("age" => array('$exists' => true)))->count();
UPDATE users SET a= WHERE b='q' $db->users->update(array("b" => "q"), array('$set' => array("a" => )));
UPDATE users SET a=a+ WHERE b='q' $db->users->update(array("b" => "q"), array('$inc' => array("a" => )));
DELETE FROM users WHERE z="abc" $db->users->remove(array("z" => "abc"));

会员反馈功能

web  leaf/leaf/feedback.php

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="<?php echo assets(TPLURL . "assets/css/bootstrap.min.css") ;?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo assets(TPLURL . "assets/css/mobile-style.css") ;?>">
<link rel="stylesheet" type="text/css" href="<?php echo assets(TPLURL . "assets/css/sweetalert.css") ;?>">
<title></title>
</head>
<body>
<header class="personal_center_header">
<div >
<a href="#" ><i><img src="<?php echo TPLURL ;?>assets/img/1_03.png" alt="" /></i><p>意见反馈</p><img src="<?php echo TPLURL ;?>assets/img/1_03.gif" alt=""/></a>
</div>
</header>
<article class="feedback_article apply_agent_article">
<form id="form-feedback">
<label><small>请留下您宝贵的意见</small></label>
<textarea placeholder="您想对我们说点什么......" name="explain" id="explain"></textarea>
<div class="address">
<small>付款截图上传</small>
<p>
<input type="file" name="pic" id="pic" class="file"/>
<strong>浏览图片</strong>
</p>
</div>
<button type="submit">确认提交</button>
</form>
</article>
<footer class="personal_center_footer">
</footer>
<script type="text/javascript" src="<?php echo assets(TPLURL . 'assets/js/jquery-2.1.3.min.js') ;?>"></script>
<script type="text/javascript" src="<?php echo assets(TPLURL . 'assets/js/bootstrap.min.js') ;?>"></script>
<script type="text/javascript" src="<?php echo assets(TPLURL . 'assets/js/sweetalert.min.js') ;?>"></script>
<script type="text/javascript" src="<?php echo assets(TPLURL . 'assets/js/common.js') ;?>"></script>
<script type="text/javascript" src="<?php echo assets(TPLURL . 'assets/js/feedback.js') ;?>"></script>
</body>
</html>

ajax 提交]

/**
* public common
* $ mod_reg 2013-06-07 00:09:13
* @author Changhe<xuwu125@gmail.com>
*/
$(function(){
feedback_init();
});
function feedback_init(){
$('#form-feedback').submit(function(){
var senddata={
explain:$('#explain').val(),
pic:$('#pic').val(),
};
if(senddata.explain.length<=){
alert("您宝贵的的意见不能少于10个汉字");
return false;
}
//连接到 _mod_mod_feed
var url='/feed/add.html?ajax=json&r='+random();
$.post(url, $(this).serialize(), function(data){
if(data.error == ){
alert(data.message);
}else{
swal(data.message);
}
});
return false;
});
}

ajax传到—mod/mod_feed.php

切忌:定义了一定要在  index。php下面配置

class mod_feed extends mobileweixin{
/**
* 意见反馈
**/
public function feed_init() { }
public function action_add() {
if($_GET['ajax'] == 'json'){
$post = $_POST;
$data=array(
'explain'=>trim($_POST['explain']),
'pic'=>trim($_POST['pic']),
'status'=>FeedbackModel::Notviewed,
'AppID'=>appid(),
);
if(empty($data['explain'])){
$this->_alert(ERROR, "您宝贵的的意见不能少于10个汉字");
}
$FeedbackModel = new FeedbackModel($data);
$FeedbackModel->save();
}
}
}

手机提交完成

后台管理—data/cpapp_nav.php添加目录

在_mod/mod_app.php 定义

    public function action_feedback() {
import('org.mod.feedback');
$app=new feedback($this);
$method_name='on_'.$this->_CF['type'];
if(method_exists($app, $method_name)){
$app->$method_name();
}else{
$this->_alert(ERROR, PARAM_ERROR);
}
}

里面引入了 system/org/mod/class.feedback.php

<?php
/**
* @用户反馈
* @author qy
* @time 2015-06-05
*/
import ( 'org.mod.ModPublic' );
class feedback extends ModPublic {
private $tab_feedback;
// 实例化 引入
function app_init() {
$this->tab_feedback = $this->mongodb ()->feedback;
$this->t->_view ['extcss'] = array (
'ext_agent'
);
$this->t->_view ['extjs'] = array (
'ext_agent'
);
}
/**
* @功能:反馈信息
* @return void
* @author qy
*
*/
public function on_index() {
$feedback = FeedbackModel::orderBy("status",)->orderBy("_id",-)->get();
$this->t->_view ['datalist'] = $feedback;
}
public function on_read() {
$id = intval($_GET['id']);
if(!$id){
$this->_alert(ERROR, '参数错误');
}
//查找ID下 对应的参数
$feedback = FeedbackModel::find ($id);
if (isset ( $_GET['id'] ) && intval ( $_GET['id'] )) {
$info = FeedbackModel::find($_GET['id']);
$info ->status = ;
$info->save();
}
//显示详情
$this->t->_view ['datalist'] = $feedback;
}
}
?>
FeedbackModel::这个是自定义了参数
特别注意 Notviewed 的引入
class FeedbackModel extends MongoLModel
{
public $collectionName = "feedback";
const Notviewed = ; //0未查看 1已查看
//自动递增
public $autoIncrement = true;
//时间戳
public $timestamp = true;
}
 

php moungoDB的更多相关文章

随机推荐

  1. POJ 1328 Radar Installation#贪心(坐标几何题)

    (- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<algorithm> #include<cmath ...

  2. Java 集合 LinkedList的ListIterator

    Java 集合 LinkedList的ListIterator @author ixenos 摘要:ListIterator<E>是继承自Iterator<E>的接口.list ...

  3. hdu_5832_A water problem(模拟)

    题目链接:hdu_5832_A water problem 这是一个惨痛的教训,想这种这么大的大数肯定就是找个规律模拟一下. 然而我们队还写JAVA,用大数艹了13发罚时,真是TM智障了. #incl ...

  4. [SOJ] 图的广度优先搜索

    Time Limit: 1sec    Memory Limit:256MB Description 读入图的邻接矩阵以及一个顶点的编号(图中顶点的编号为从1开始的连续正整数.顶点在邻接矩阵的行和列上 ...

  5. JS 之设置元素样式的改变,可以利用样式框架

    如果已经将某个元素的样式设定好了,又想改变,可以利用样式框架: function setStyle(obj,attr,value){ obj.style[attr]=value;//注意此处attr的 ...

  6. ASP.NET MVC 实现AJAX跨域请求的两种方法

    通常发送AJAX请求都是在本域内完成的,也就是向本域内的某个URL发送请求,完成部分页面的刷新.但有的时候需要向其它域发送AJAX请求,完成数据的加载,例如Google. 在ASP.NET MVC 框 ...

  7. 网络传输中的三张表,MAC地址表、ARP缓存表以及路由表

    一:MAC地址表详解 说到MAC地址表,就不得不说一下交换机的工作原理了,因为交换机是根据MAC地址表转发数据帧的.在交换机中有一张记录着局域网主机MAC地址与交换机接口的对应关系的表,交换机就是根据 ...

  8. css sprite的使用心得

    提高网页显示速度最有效的一个方法是减少页面的HTTP请求次数,为了减少HTTP请求次数,最直接有效的方法是使用精灵图片(CSS sprites),精灵图片是把许多图片放到一张大图片里面,通过CSS来显 ...

  9. 学习笔记——备忘录模式Memento

    备忘录模式,可以将当前状态保存,并随时恢复. Originator存在状态state,当需要保存此状态时,通过CreateMemento创建一个备忘录对象Memento保存此状态:而需要恢复相应状态时 ...

  10. RIDE的使用

    在RIDE中,CTRL + R 自动打开report.html , CTRL + L 自动打开 log.html