Example #1
0
static Variant HHVM_FUNCTION(mysql_fetch_object,
                      const Variant& var_result,
                      const String& class_name /* = "stdClass" */,
                      const Variant& params /* = null */) {

  Resource result = var_result.isResource() ? var_result.toResource()
                                            : null_resource;
  Variant properties = php_mysql_fetch_hash(result, PHP_MYSQL_ASSOC);
  if (!same(properties, false)) {
    Object obj;

    const auto paramsArray = params.isArray()
      ? params.asCArrRef()
      : Array();

    // We need to create an object without initialization (constructor call),
    // and set the fetched fields as dynamic properties on the object prior
    // calling the constructor.
    obj = create_object_only(class_name);

    // Set the fields.
    obj->o_setArray(properties.toArray());

    // And finally initialize the object by calling the constructor.
    obj = init_object(class_name, paramsArray, obj.get());

    return obj;
  }

  return false;
}
Example #2
0
Variant f_mysql_fetch_object(CVarRef result,
                             const String& class_name /* = "stdClass" */,
                             CArrRef params /* = null */) {
  Variant properties = php_mysql_fetch_hash(result, PHP_MYSQL_ASSOC);
  if (!same(properties, false)) {
    Object obj = create_object(class_name, params);
    obj->o_setArray(properties.toArray());

    return obj;
  }
  return false;
}
Example #3
0
static Variant HHVM_FUNCTION(mysql_fetch_object,
                      const Variant& var_result,
                      const String& class_name /* = "stdClass" */,
                      const Variant& params /* = null */) {
  Resource result = var_result.isResource() ? var_result.toResource()
                                            : null_resource;
  Variant properties = php_mysql_fetch_hash(result, PHP_MYSQL_ASSOC);
  if (!same(properties, false)) {
    Object obj;
    if (params.isArray()) {
      obj = create_object(class_name, params.asCArrRef());
    } else {
      obj = create_object(class_name, Array());
    }
    obj->o_setArray(properties.toArray());

    return obj;
  }
  return false;
}
Example #4
0
Variant f_mysql_fetch_array(CVarRef result, int result_type /* = 3 */) {
  return php_mysql_fetch_hash(result, result_type);
}
Example #5
0
Variant f_mysql_fetch_assoc(CVarRef result) {
  return php_mysql_fetch_hash(result, PHP_MYSQL_ASSOC);
}
Example #6
0
Variant f_mysql_fetch_row(CVarRef result) {
  return php_mysql_fetch_hash(result, PHP_MYSQL_NUM);
}
Example #7
0
Variant f_mysql_fetch_array(const Variant& result, int result_type /* = 3 */) {
  return php_mysql_fetch_hash(result, result_type);
}
Example #8
0
Variant f_mysql_fetch_assoc(const Variant& result) {
  return php_mysql_fetch_hash(result, PHP_MYSQL_ASSOC);
}
Example #9
0
Variant f_mysql_fetch_row(const Variant& result) {
  return php_mysql_fetch_hash(result, PHP_MYSQL_NUM);
}
Example #10
0
static Variant HHVM_FUNCTION(mysql_fetch_array, const Resource& result,
                                         int result_type /* = 3 */) {
  return php_mysql_fetch_hash(result, result_type);
}