codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.22k stars 1.87k forks source link

About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE #1979

Closed viosion closed 5 years ago

viosion commented 5 years ago

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

jim-parry commented 5 years ago

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


From: Haibin notifications@github.com Sent: Wednesday, May 1, 2019 8:02 PM To: codeigniter4/CodeIgniter4 Cc: Subscribed Subject: [codeigniter4/CodeIgniter4] About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE (#1979)

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

- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/codeigniter4/CodeIgniter4/issues/1979, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYOG33NB7DLRSQWC7TZE3DPTJKSXANCNFSM4HJ3CWNQ.

viosion commented 5 years ago

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 commented 5 years ago

The google captcha was removed some time ago.

Jim Parry Faculty, Computer Systems Project Lead, CodeIgniterhttps://codeigniter.com


From: Haibin notifications@github.com Sent: Wednesday, May 1, 2019 10:10 PM To: codeigniter4/CodeIgniter4 Cc: James Parry; Comment Subject: Re: [codeigniter4/CodeIgniter4] About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE (#1979)

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.

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/codeigniter4/CodeIgniter4/issues/1979#issuecomment-488555005, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYOG32DVRAQT5MU5ZZJ6R3PTJZV3ANCNFSM4HJ3CWNQ.

nowackipawel commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

Will investigate, thanks!

Jim Parry Faculty, Computer Systems Project Lead, CodeIgniterhttps://codeigniter.com


From: Haibin notifications@github.com Sent: Thursday, May 2, 2019 6:54 AM To: codeigniter4/CodeIgniter4 Cc: James Parry; Comment Subject: Re: [codeigniter4/CodeIgniter4] About mysqli options MYSQLI_OPT_INT_AND_FLOAT_NATIVE (#1979)

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]https://user-images.githubusercontent.com/25802553/57077574-fba74280-6d1e-11e9-9f22-1af774d26f69.jpg [1556802693129]https://user-images.githubusercontent.com/25802553/57077591-0661d780-6d1f-11e9-9e2b-14a0208bdfc4.jpg [1556802706169]https://user-images.githubusercontent.com/25802553/57077599-0a8df500-6d1f-11e9-98be-37e8b45170b4.jpg

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/codeigniter4/CodeIgniter4/issues/1979#issuecomment-488682480, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAYOG3ZWDWF5UXF6RNMB2I3PTLXAXANCNFSM4HJ3CWNQ.

viosion commented 5 years ago

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~.

LoganTann commented 2 years ago

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

kenjis commented 10 months ago

See #7265