小黑小波比.sql.read方法

因为要读取多条数据,所以要用read方法

searchlicense: {
		attribute: {
			//"admin": true
		},
		method: function(e) {
			var _ = this.apis;
			var sql = "select * from userbase e left join user_teacher r on e.ucode=r.ucode where e.uname like :search or e.status=:status or r.applytime=:start limit 20";
			//or e.status=:status or r.applytime=:start
			//这里是read方法不同于query
			var result = [];
			_.sql.read(sql, {
				status: e.params.status,
				search: e.params.search +'%',//添加符号 等同于
				start: e.params.start
			}, function(row) {
				result.push({ //数组
					ucode: row.ucode,
					applycode:row.applycode,
					uname: row.uname,
					ufile:row.applyinfo,
					status:row.validate
				});
			}).success(function() {
				e.result({
					applys:result
				});
			}).failure(function() {
				e.result({
					status: 2
				});
			});
		}
	},


你可能感兴趣的:(js,小黑小波比,服务端js)