本文整理汇总了C++中MySQLResult::seekField方法的典型用法代码示例。如果您正苦于以下问题:C++ MySQLResult::seekField方法的具体用法?C++ MySQLResult::seekField怎么用?C++ MySQLResult::seekField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLResult
的用法示例。
在下文中一共展示了MySQLResult::seekField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_mysql_fetch_field
Variant f_mysql_fetch_field(CVarRef result, int field /* = -1 */) {
MySQLResult *res = php_mysql_extract_result(result);
if (res == NULL) return false;
if (field != -1) {
if (!res->seekField(field)) return false;
}
MySQLFieldInfo *info;
if (!(info = res->fetchFieldInfo())) return false;
Object obj(SystemLib::AllocStdClassObject());
obj->o_set("name", info->name);
obj->o_set("table", info->table);
obj->o_set("def", info->def);
obj->o_set("max_length", (int)info->max_length);
obj->o_set("not_null", IS_NOT_NULL(info->flags)? 1 : 0);
obj->o_set("primary_key", IS_PRI_KEY(info->flags)? 1 : 0);
obj->o_set("multiple_key", info->flags & MULTIPLE_KEY_FLAG? 1 : 0);
obj->o_set("unique_key", info->flags & UNIQUE_KEY_FLAG? 1 : 0);
obj->o_set("numeric", IS_NUM(info->type)? 1 : 0);
obj->o_set("blob", IS_BLOB(info->flags)? 1 : 0);
obj->o_set("type", php_mysql_get_field_name(info->type));
obj->o_set("unsigned", info->flags & UNSIGNED_FLAG? 1 : 0);
obj->o_set("zerofill", info->flags & ZEROFILL_FLAG? 1 : 0);
return obj;
}
示例2: php_mysql_field_info
Variant php_mysql_field_info(const Variant& result, int field, int entry_type) {
MySQLResult *res = php_mysql_extract_result(result);
if (res == NULL) return false;
if (!res->seekField(field)) return false;
MySQLFieldInfo *info;
if (!(info = res->fetchFieldInfo())) return false;
switch (entry_type) {
case PHP_MYSQL_FIELD_NAME:
return info->name;
case PHP_MYSQL_FIELD_TABLE:
return info->table;
case PHP_MYSQL_FIELD_LEN:
return info->length;
case PHP_MYSQL_FIELD_TYPE:
return php_mysql_get_field_name(info->type);
case PHP_MYSQL_FIELD_FLAGS:
{
char buf[512];
buf[0] = '\0';
unsigned int flags = info->flags;
#ifdef IS_NOT_NULL
if (IS_NOT_NULL(flags)) {
strcat(buf, "not_null ");
}
#endif
#ifdef IS_PRI_KEY
if (IS_PRI_KEY(flags)) {
strcat(buf, "primary_key ");
}
#endif
#ifdef UNIQUE_KEY_FLAG
if (flags & UNIQUE_KEY_FLAG) {
strcat(buf, "unique_key ");
}
#endif
#ifdef MULTIPLE_KEY_FLAG
if (flags & MULTIPLE_KEY_FLAG) {
strcat(buf, "multiple_key ");
}
#endif
#ifdef IS_BLOB
if (IS_BLOB(flags)) {
strcat(buf, "blob ");
}
#endif
#ifdef UNSIGNED_FLAG
if (flags & UNSIGNED_FLAG) {
strcat(buf, "unsigned ");
}
#endif
#ifdef ZEROFILL_FLAG
if (flags & ZEROFILL_FLAG) {
strcat(buf, "zerofill ");
}
#endif
#ifdef BINARY_FLAG
if (flags & BINARY_FLAG) {
strcat(buf, "binary ");
}
#endif
#ifdef ENUM_FLAG
if (flags & ENUM_FLAG) {
strcat(buf, "enum ");
}
#endif
#ifdef SET_FLAG
if (flags & SET_FLAG) {
strcat(buf, "set ");
}
#endif
#ifdef AUTO_INCREMENT_FLAG
if (flags & AUTO_INCREMENT_FLAG) {
strcat(buf, "auto_increment ");
}
#endif
#ifdef TIMESTAMP_FLAG
if (flags & TIMESTAMP_FLAG) {
strcat(buf, "timestamp ");
}
#endif
int len = strlen(buf);
/* remove trailing space, if present */
if (len && buf[len-1] == ' ') {
buf[len-1] = 0;
len--;
}
return String(buf, len, CopyString);
}
default:
break;
}
return false;
}
示例3: f_mysql_field_seek
bool f_mysql_field_seek(CVarRef result, int field /* = 0 */) {
MySQLResult *res = php_mysql_extract_result(result);
if (res == NULL) return false;
return res->seekField(field);
}
示例4: f_mysql_result
Variant f_mysql_result(CVarRef result, int row,
CVarRef field /* = null_variant */) {
MySQLResult *res = php_mysql_extract_result(result);
if (res == NULL) return false;
MYSQL_RES *mysql_result = NULL;
MYSQL_ROW sql_row = NULL;
unsigned long *sql_row_lengths = NULL;
if (res->isLocalized()) {
if (!res->seekRow(row)) return false;
if (!res->fetchRow()) return false;
} else {
mysql_result = res->get();
if (row < 0 || row >= (int)mysql_num_rows(mysql_result)) {
raise_warning("Unable to jump to row %d on MySQL result index %d",
row, result.toResource()->o_getId());
return false;
}
mysql_data_seek(mysql_result, row);
sql_row = mysql_fetch_row(mysql_result);
if (!sql_row) {
return false;
}
sql_row_lengths = mysql_fetch_lengths(mysql_result);
if (!sql_row_lengths) {
return false;
}
}
int field_offset = 0;
if (!field.isNull()) {
if (field.isString()) {
String sfield = field.toString();
const char *tmp = strchr(sfield.data(), '.');
String table_name, field_name;
if (tmp) {
int pos = tmp - sfield.data();
table_name = sfield.substr(0, pos);
field_name = sfield.substr(pos + 1);
} else {
field_name = sfield;
}
int i = 0;
bool found = false;
res->seekField(0);
while (i < res->getFieldCount()) {
MySQLFieldInfo *info = res->getFieldInfo(i);
if ((table_name.empty() || table_name.same(info->table)) &&
field_name.same(info->name)) {
field_offset = i;
found = true;
break;
}
i++;
}
if (!found) { /* no match found */
raise_warning("%s%s%s not found in MySQL result index %d",
table_name.data(), (table_name.empty() ? "" : "."),
field_name.data(), result.toResource()->o_getId());
return false;
}
} else {
field_offset = field.toInt32();
if (field_offset < 0 ||
field_offset >= (int)res->getFieldCount()) {
raise_warning("Bad column offset specified");
return false;
}
}
}
if (res->isLocalized()) {
Variant f = res->getField(field_offset);
if (!f.isNull()) {
return f.toString();
}
} else {
if (sql_row[field_offset]) {
return String(sql_row[field_offset], sql_row_lengths[field_offset],
CopyString);
}
}
return uninit_null();
}
示例5: HHVM_FUNCTION
static bool HHVM_FUNCTION(mysql_field_seek, const Resource& result, int field) {
MySQLResult *res = php_mysql_extract_result(result);
if (res == NULL) return false;
return res->seekField(field);
}