遇到玉和循环问题时,会从 mysql 查询中抛出一个数组。当我console.log
连续尝试记录它时,它会输出这个。
{ id: 512,
first: 'Mark',
last: 'Neal',
client: 'City of South Bend',
employer: null,
access: null }
这很好。
现在我正在尝试设置它,以便玉将自动填写列名和列。无论如何,这是我的玉代码。
block content
.container
h1 Data Tables
.span12
table.table.table-striped.table-bordered.table-condensed
thead
each f in fields
th= f.name
tbody
each i in results
tr
each b in i
td= b
显然我不能发布图片,因为这是我的第一篇文章,所以我会尽我所能尝试复制和粘贴。
而不是停在}
它继续这样在两个新列中。
function (parser, fieldPackets, typeCast, nestTables, connection) {
var self = this;
var next = function () {
return self._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings);
};
for (var i = 0; i < fieldPackets.length; i++) {
var fieldPacket = fieldPackets[i];
var value;
if (typeof typeCast == "function") {
value = typeCast.apply(connection, [new Field({
packet: fieldPacket,
parser: parser
}), next]);
} else {
value = (typeCast) ? this._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings) : ((fieldPacket.charsetNr === Charsets.BINARY) ? parser.parseLengthCodedBuffer() : parser.parseLengthCodedString());
} if (typeof nestTables == "string" && nestTables.length) {
this[fieldPacket.table + nestTables + fieldPacket.name] = value;
} else if (nestTables) {
this[fieldPacket.table] = this[fieldPacket.table] || {};
this[fieldPacket.table][fieldPacket.name] = value;
} else {
this[fieldPacket.name] = value;
}
}
}
function (field, parser, timeZone, supportBigNumbers, bigNumberStrings) {
var numberString;
switch (field.type) {
case Types.TIMESTAMP:
case Types.DATE:
case Types.DATETIME:
case Types.NEWDATE:
var dateString = parser.parseLengthCodedString();
var dt;
if (dateString === null) {
return null;
}
if (timeZone != 'local') {
if (field.type === Types.DATE) {
dateString += ' 00:00:00 ' + timeZone;
} else {
dateString += ' ' + timeZone;
}
}
dt = new Date(dateString);
if (isNaN(dt.getTime())) {
return dateString;
}
return dt;
case Types.TINY:
case Types.SHORT:
case Types.LONG:
case Types.INT24:
case Types.YEAR:
case Types.FLOAT:
case Types.DOUBLE:
numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] == "0")) ? numberString : Number(numberString);
case Types.NEWDECIMAL:
case Types.LONGLONG:
numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] == "0")) ? numberString : ((supportBigNumbers && (bigNumberStrings || (Number(numberString) > IEEE_754_BINARY_64_PRECISION))) ? numberString : Number(numberString));
case Types.BIT:
return parser.parseLengthCodedBuffer();
case Types.STRING:
case Types.VAR_STRING:
case Types.TINY_BLOB:
case Types.MEDIUM_BLOB:
case Types.LONG_BLOB:
case Types.BLOB:
return (field.charsetNr === Charsets.BINARY) ? parser.parseLengthCodedBuffer() : parser.parseLengthCodedString();
case Types.GEOMETRY:
return parser.parseGeometryValue();
default:
return parser.parseLengthCodedString();
}
}