Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE #1979

Closed
viosion opened this issue May 2, 2019 · 9 comments
Closed

About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE #1979

viosion opened this issue May 2, 2019 · 9 comments

Comments

@viosion
Copy link
Contributor

viosion commented May 2, 2019

I am sorry to post the question here. I can't open the forum, I think because the Chinese network has blocked some websites, such as google. I have no time to configure a vpn recently.

Describe the bug
I have a problem, MySQL query results need to return integer and float, but mysql 5.7 defaults to return integer and float as a string type. So I need to use a configuration, MYSQLI_OPT_INT_AND_FLOAT_NATIVE. In CodeIgniter 3, I can do this:
$db->conn_id->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, TRUE);
But CodeIgniter 4, this method is no longer useful.
$db->connID->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, TRUE);
This doesn't work either.

I want to know, there is any good way to use mysqli's options directly, without changing the framework source.

In addition, regarding MYSQLI_OPT_INT_AND_FLOAT_NATIVE, can you consider making a configurable item and implementing it directly in the Mysqli driver.

CodeIgniter 4 version
CodeIgniter 4.0.0 beta.2

Context

  • OS: Mac OS 10.14.4
  • Web server [Nginx 1.13.2]
  • PHP version [7.2.14]
@jim-parry
Copy link
Contributor

jim-parry commented May 2, 2019 via email

@viosion
Copy link
Contributor Author

viosion commented May 2, 2019

There are a number of users in China who have no problem accessing the forum from there, and I have done so myself. I don't know enough to answer your question, but it is definitely something for the forum, as we use github for bug tracking and planned work. ps - I was unable to access google from China, but most sites, including our forum, were not blocked. Jim Parry Faculty, Computer Systems Project Lead, CodeIgniterhttps://codeigniter.com

The forum can be accessed, but the account cannot be registered. If I am not mistaken, the forum registration uses the google verification code. Although it is not a big problem, it still takes a certain amount of work to overturn the wall. China's network Great Wall is a helpless and sad system.
Thanks for your reply~ After a few days, when I have time, I will try a vpn. If the forum can solve the problem of google verification code, it will be more convenient for other people.

@jim-parry
Copy link
Contributor

jim-parry commented May 2, 2019 via email

@nowackipawel
Copy link
Contributor

nowackipawel commented May 2, 2019

I know is not a place to write about it, but...
unfortunately, I think the easiest option is to extend MySQLi/Connection or Model class and add there support for required options.
I will be able to add code which will allow to do so using database's config, but I won't have time for writing tests and the same functionality for other db drivers :(

@viosion
Copy link
Contributor Author

viosion commented May 2, 2019

The google captcha was removed some time ago. Jim Parry Faculty, Computer Systems Project Lead, CodeIgniterhttps://codeigniter.com

Maybe the google captcha hasn't been removed yet....

1556802688333
1556802693129
1556802706169

@jim-parry
Copy link
Contributor

jim-parry commented May 2, 2019 via email

@viosion
Copy link
Contributor Author

viosion commented May 2, 2019

I know is not a place to write about it, but...
unfortunately, I think the easiest option is to extend MySQLi/Connection or Model class and add there support for required options.
I will be able to add code which will allow to do so using database's config, but I won't have time for writing tests and the same functionality for other db drivers :(

Thanks for your suggestion, I extended the model. To use mysqli options, I need a real connection connID, but the connID will only exist when the query is actually connected to the database. So I had to use $db->initialize() first in the constructor of the model, then execute options(); I don't know is this will affect the efficiency of the on-demand connection.

it's ok, thank you, and thanks jim parry again~.

@viosion viosion closed this as completed May 2, 2019
@LoganTann
Copy link

I used this stackoverflow answer and it works :
$this->db->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);

@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

See #7265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants