Re: docs on mysqli_query return values are incorrect.

j adams <[email protected]>
Newsgroups gmane.comp.php.documentation.general
Message-ID <CADbOR2gLtitYJLCLq953z0s5hM+1dstGDKsYQs8AJVMwx6_SZA@mail.gmail.com>
Are you sure? The result sets returned by mysqli_query do, in fact,
indicate the success or failure of the OPTIMIZE TABLE result.  For a
successful result:

array(8) {
  [0]=>
  string(15) "ci4_test.db_job"
  ["Table"]=>
  string(15) "ci4_test.db_job"
  [1]=>
  string(8) "optimize"
  ["Op"]=>
  string(8) "optimize"
  [2]=>
  string(4) "note"
  ["Msg_type"]=>
  string(4) "note"
  [3]=>
  string(65) "Table does not support optimize, doing recreate + analyze
instead"
  ["Msg_text"]=>
  string(65) "Table does not support optimize, doing recreate + analyze
instead"
}
array(8) {
  [0]=>
  string(15) "ci4_test.db_job"
  ["Table"]=>
  string(15) "ci4_test.db_job"
  [1]=>
  string(8) "optimize"
  ["Op"]=>
  string(8) "optimize"
  [2]=>
  string(6) "status"
  ["Msg_type"]=>
  string(6) "status"
  [3]=>
  string(2) "OK"
  ["Msg_text"]=>
  string(2) "OK"
}


For a non-existent table (i.e, a failure):

array(8) {
  [0]=>
  string(15) "ci4_test.db_joe"
  ["Table"]=>
  string(15) "ci4_test.db_joe"
  [1]=>
  string(8) "optimize"
  ["Op"]=>
  string(8) "optimize"
  [2]=>
  string(5) "Error"
  ["Msg_type"]=>
  string(5) "Error"
  [3]=>
  string(37) "Table 'ci4_test.db_joe' doesn't exist"
  ["Msg_text"]=>
  string(37) "Table 'ci4_test.db_joe' doesn't exist"
}
array(8) {
  [0]=>
  string(15) "ci4_test.db_joe"
  ["Table"]=>
  string(15) "ci4_test.db_joe"
  [1]=>
  string(8) "optimize"
  ["Op"]=>
  string(8) "optimize"
  [2]=>
  string(6) "status"
  ["Msg_type"]=>
  string(6) "status"
  [3]=>
  string(16) "Operation failed"
  ["Msg_text"]=>
  string(16) "Operation failed"
}



On Mon, Jan 4, 2021 at 4:28 PM Kamil Tekiela <[email protected]> wrote:

> The documentation is correct (at least that part) but what you have
> encountered is a bug, either in mysqli or in MySQL. Please file a bug
> report on https://bugs.php.net/ and we will look into it.
>
> On Tue, 5 Jan 2021 at 00:12, j adams <[email protected]> wrote:
>
>> Hello! Apologies if I'm emailing the wrong list.
>>
>> There is a problem with the return value description for mysqli_query,
>> displayed here:
>> https://www.php.net/manual/en/mysqli.query.php
>>
>> Under 'Return Values,' it says:
>>
>> >Returns *false* on failure. For successful SELECT, SHOW, DESCRIBE or
>> EXPLAIN queries *mysqli_query()* will return a mysqli_result
>> <https://www.php.net/manual/en/class.mysqli-result.php> object. For
>> other successful queries *mysqli_query()* will return *true*
>>
>> This is not correct. I can provide one counterexample, which is when you
>> run an optimize query:
>>
>> OPTIMIZE TABLE my_table;
>>
>> This query will return a result set with two records whether the table
>> exists or not.
>>
>>
>> I believe I found the file that should be altered on github here:
>>
>> https://github.com/php/doc-en/blob/master/reference/mysqli/mysqli/query.xml#L111
>>
>> I do not know what the return value description should be under all the
>> various circumstances.
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.