Okay, so I'm getting my MySQL Version like so:
preg_replace('#[^0-9\.]#', '', mysql_get_server_info());
Which gives me a number like: 5.1.36
That's all good. What I need to do, is compare that version with another version. I was about to attempt to write my function to compare them, when I thought of version_compare()
. However, upon testing I became unsure, but perhaps I'm just not sure how MySQL Version Numbers work.
This is what I tested:
version_compare('5.1.36', '5.1.4', '<');
or
5.1.36 < 5.1.4
I assumed that this would return true, that 5.1.36 is less than 5.1.4. My reason for that is, I figure 5.1.4 is actually 5.1.40 not 5.1.04. Perhaps I'm wrong there.
So am I thinking wrong, or is the function returning the incorrect result?
The function is correct. The numbering system is M.m.r where each "number" is a decimal number.
So 5.1.36 would be revision 36 of the 5.1 minor version... Therefore, 5.1.4 would be revision 4 (and hence 36 > 4)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With