我试图限制排名功能,但我似乎无法使其发挥作用。我错过了什么?到目前为止,我在外部查询上使用了WHERE / HAVING函数: WHERE rank< 10 但我得到的错误是没有Rank Column。
我一直在四处寻找,很多人也使用了别名。
- (void)reloadConnections{
for (CAShapeLayer *shapelayer in self.connectionLines) {
[shapelayer removeFromSuperlayer];
}
self.connectionLines = [NSMutableArray array];
for (int i = 0; i <= (self.total-2); i++){
NSArray *paths = [self pathForconnectionLineForIndexPath:i];
for (UIBezierPath *path in paths) {
UIColor *color = (self.currentLevel > i) ? [UIColor colorWithRed:0.078 green:0.557 blue:0.067 alpha:1.00] : [UIColor colorWithRed:0.957 green:0.659 blue:0.024 alpha:1.00];
CAShapeLayer *shapelayer = [self drawdottedLineWithPath:path withborderWidth:1.0f withColor:color];
[self.collectionView.layer addSublayer:shapelayer];
[self.connectionLines addObject:shapelayer];
}
}
}
- (NSArray *)pathForconnectionLineForIndexPath:(int)index{
NSMutableArray *paths = [NSMutableArray array];
int row = index%self.noOfItems;
int column = index/self.noOfItems;
CGFloat cellWidth = self.view.frame.size.width/self.noOfItems;
CGFloat cellHeight = self.view.frame.size.width/self.noOfItems;
CGFloat connectionLength = cellHeight/2;
CGFloat leftPadding;
CGFloat topPadding;
if (row != (self.noOfItems-1)) {
leftPadding = cellWidth/4;
topPadding = cellHeight/2;
UIBezierPath *borderPath = [UIBezierPath bezierPath];
CGFloat startX = (3*leftPadding)+(row*cellWidth);
CGFloat startY = topPadding+(column*cellHeight);
CGFloat endX = startX + connectionLength;
CGFloat endY = startY;
[borderPath moveToPoint:CGPointMake(startX , startY)];
[borderPath addLineToPoint:CGPointMake(endX, endY)];
[self drawDirectionAt:CGPointMake((startX+(connectionLength/2)) , startY) isEnabled:(self.currentLevel > index) isRight:YES];
[paths addObject:borderPath];
}
if ( (row == (self.noOfItems-1)) && (column%2 == 0) ) {
leftPadding = cellWidth/2;
topPadding = cellHeight/8;
UIBezierPath *borderPath = [UIBezierPath bezierPath];
CGFloat startX = leftPadding+(row*cellWidth);
CGFloat startY = (7*topPadding)+(column*cellHeight);
CGFloat endX = startX;
CGFloat endY = startY + (2*topPadding);
[borderPath moveToPoint:CGPointMake(startX , startY)];
[borderPath addLineToPoint:CGPointMake(endX, endY)];
[self drawDirectionAt:CGPointMake(startX , (startY+topPadding)) isEnabled:(self.currentLevel > index) isRight:NO];
[paths addObject:borderPath];
}
if ( (row == 0) && (column%2 != 0) ) {
leftPadding = cellWidth/2;
topPadding = cellHeight/8;
UIBezierPath *borderPath = [UIBezierPath bezierPath];
CGFloat startX = leftPadding+(row*cellWidth);
CGFloat startY = (7*topPadding)+(column*cellHeight);
CGFloat endX = startX;
CGFloat endY = startY + (2*topPadding);
[borderPath moveToPoint:CGPointMake(startX , startY)];
[borderPath addLineToPoint:CGPointMake(endX, endY)];
[self drawDirectionAt:CGPointMake(startX , (startY+topPadding)) isEnabled:(self.currentLevel > index) isRight:NO];
[paths addObject:borderPath];
}
return paths;
}
- (CAShapeLayer *)drawdottedLineWithPath:(UIBezierPath *)path withborderWidth:(CGFloat)lineWidth withColor: (UIColor *)color
{
CAShapeLayer *shapelayer = [CAShapeLayer layer];
shapelayer.strokeStart = 0.0;
shapelayer.strokeColor = color.CGColor;
shapelayer.lineWidth = lineWidth;
shapelayer.lineJoin = kCALineJoinRound;
shapelayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:15],[NSNumber numberWithInt:10 ], nil];
shapelayer.path = path.CGPath;
return shapelayer;
}
- (void)drawDirectionAt:(CGPoint)point isEnabled:(BOOL)enabled isRight:(BOOL)isRight{
NSString *imageName;
imageName = isRight ? @"right-arrow" : @"down-arrow";
imageName = [NSString stringWithFormat:@"%@-%@",imageName,(enabled ? @"enabled" : @"disabled")];
CAShapeLayer* direction = [CAShapeLayer layer];
direction.opacity = 1.0;
direction.frame = CGRectMake(0, 0, 16, 16);
direction.position = point;
[direction setContents:(id)[[UIImage imageNamed: imageName] CGImage]];
[self.connectionLines addObject:direction];
[self.collectionView.layer addSublayer: direction];
}
答案 0 :(得分:1)
您不能在查询本身中使用别名,您应该将它全部包装在外部查询中:
$.ajax('http://172.16.198.19/getData.jsonp', {
type: 'get',
dataType: 'jsonp',
jsonp: false,
jsonpCallback: 'parseData'
}).done(function(data) {
console.log(data.sensor[0].tc);
}).fail(function() {
console.log("nope");
});
}