本文整理汇总了C++中MySQLResult::fetchFieldInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ MySQLResult::fetchFieldInfo方法的具体用法?C++ MySQLResult::fetchFieldInfo怎么用?C++ MySQLResult::fetchFieldInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLResult
的用法示例。
在下文中一共展示了MySQLResult::fetchFieldInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}