Site icon Hip-Hop Website Design and Development

Find out how to set MYSQLI_OPT_INT_AND_FLOAT_NATIVE choice

I am having troubles with the mysqli driver utilized by wordpress, the place it’s changing every integer worth to a string inside $wpdb->get_results("SELECT...").
I do know that it’s potential so use the the choice MYSQLI_OPT_INT_AND_FLOAT_NATIVE with the mysqli driver ($mysqli->choices(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);) however I do not appear to discover a option to set this feature in wordpress.
How do I try this?

Thanks

EDIT

Based mostly on the feedback under, I’b higher additional clarify what I am attempting to attain.
I am creating a plugin so as to add reactive/responsive functionalities to wordpress each within the backend and within the frontend (precisely like Gutenberg).
In my plugin I must entry a wide range of constructions within the database, and I am doing that utilizing utilizing AJAX together with VueJS which makes in depth use of observables.
As an example, for instance that I’ve a construction like this within the database:

CREATE TABLE IF NOT EXISTS `a_table` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `identify` VARCHAR(190) NOT NULL DEFAULT 'New identify',
    `anInteger` INT NOT NULL DEFAULT '123',
    `aBoolean` BOOLEAN NOT NULL DEFAULT TRUE
    PRIMARY KEY (`id`), UNIQUE KEY `identify` (`identify`));"

and that I am accessing the desk through AJAX to bind the info to one thing like this in Vue:

<template>
  <el-form
    :mannequin="aTable"
    ref="tableForm">
    <el-row>
      <el-col :span="4">
        <el-form-item
          label="Identify"
          prop="identify">
          <el-input
            v-model="aTable.identify">
          </el-input>
        </el-form-item>
      </el-col>
      <el-col :span="2">
        <el-form-item label="BoolVal" prop="aBoolean">
          <el-switch v-model="aTable.aBoolean"></el-switch>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="NumberVal" prop="anInteger">
          <el-input-number v-model="aTable.anInteger"></el-input-number>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  props: {
    aTable: {
      kind: Object,
      default: operate() {
        return {};
      }
    }
  },
  knowledge() {
    return {
    };
  },
  strategies: {
  }
};
</script>

//AJAX and different glue code omitted

With this arrange, the enter filed “identify” is accurately certain and shows the string “new identify”, whereas the boolean swap exhibits all the time false (VueJS is anticipating a boolean or, no less than, an integer, and is getting a string as an alternative!).
This forces me to control the outcomes I get from $wpdb earlier than returning the dataset to the AJAX caller if I would like VueJS perceive accurately what I retrieve from the database, like this:

static operate ajax_get_table()
{
    international $wpdb;
    $response = $wpdb->get_results("SELECT * FROM `a_table` WHERE 1=1 ORDER BY `id`");

    // MYSQLI_OPT_INT_AND_FLOAT_NATIVE Hack
    // mysql is returning every integer/boolean as a string
    // This hack is required to retrieve appropriate knowledge kind
    array_walk($response, operate(&$merchandise, $key) {
        array_walk($merchandise, operate(&$subitem, $subkey) {
            // Integers
            if (in_array($subkey, ['id', 'anInteger'])) $subitem = intval($subitem);
            // Boolenas
            if (in_array($subkey, ['aBoolean'])) $subitem = boolval($subitem);
        });
    });

    // AJAX termination
    wp_send_json($response);
    die();
}

However which means that I’ve to know prematurely every finish each knowledge kind returned from the MYSQL question, which is by far an anti-pattern programming approach.

That is why I am questioning why is WordPress caught to this pre-PHP-5.3 limitation.