prepare an SQL statement like:
$query = " select TABLE_NAME as TABLENAME, COLUMN_NAME as COLUMNNAME, COLUMN_TYPE as COLUMNTYPE, COLUMN_COMMENT as COLUMNCOMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'demo_database' ORDER BY TABLE_NAME, ORDINAL_POSITION ";
use the jDatabase driver to submit it to your database (MySQL).
returning an array of result-objects with all columns for all tables in that database (e.g. demo_database). Each object has the data (tablename, columnname, type, comment) for a specific column.
Joomla 3.5.1 : returns as expected
Joomla 3.6.0-rc: returns an array of result-objects, but no data in each object (see output example below). There are as many result-objects as expected, but they are "only titles, no values"
Windows Server, Apache Server 2.4, PHP 7.0.7, MariaDB 10.0.17
Returning array in Joomla 3.6.0-rc:
Array (
[0] => stdClass Object (
[TABLENAME] =>
[COLUMNNAME] =>
[COLUMNTYPE] =>
[COLUMNCOMMENT] =>
)
[1] => stdClass Object (
[TABLENAME] =>
[COLUMNNAME] =>
[COLUMNTYPE] =>
[COLUMNCOMMENT] =>
)
...
Not fully sure what you expect as answer...
I use the following procedure (though a bit more complex in reality):
$db = JFactory::getDBO();
$query = " select TABLE_NAME as TABLENAME, COLUMN_NAME as COLUMNNAME, COLUMN_TYPE as COLUMNTYPE, COLUMN_COMMENT as COLUMNCOMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'demo_database' ORDER BY TABLE_NAME, ORDINAL_POSITION ";
$db->setQuery( $query );
$result = $db->execute();
$return = $db->loadObjectList();
I have never tried or seen such a code:
$result = $db->execute();
$return = $db->loadObjectList();
if the above code ever worked, it is a "side-effect" which you should have never relied on
your code should be:
$return = $db->loadObjectList();
Can you provide a link to docs or to other text that suggests, using the code the way that you tried ?
Labels |
Added:
?
|
I just checked https://docs.joomla.org/Selecting_data_using_JDatabase
and together with your comment above, I feel I understand better now (thank you) - seems like my misunderstanding of the whole thing.
However, this certainly works without issues in a Joomla 3.5 environment (in fact on a several hundred websites all over the world in most different environments - and since Joomla 2.5).
So I will try this "without" the explicit "execute" statement and get back with the results...
Looking at the bottom of the document link,
So if there is a such a change,
then it is a B/C break or probably better call it a bug introduced by J3.6.0 RC
But i can not replicate the issue you report
1 query a some DB table
1 query getting data from information_schema
and it worked in both cases
$result = $db->execute();
$return = $db->loadObjectList();
Are the 2 sites identical and only change is the upgrade to J3.6.0 RC?
@ggppdk: You can use that code for example to get num_rows. It is documented as regular Joomla method.
$db->setQuery($query);
$db->execute();
$num_rows = $db->getNumRows();
print_r($num_rows);
$result = $db->loadRowList();
@franzpeter
yes, i recognized that such usage is allowed
Looking at the bottom of the document link,
i see such usage as you are using originally !
of course you don't need call getNumRows() , if you have already called loadRowList() or loadObjectList ... because you already know how many rows you have
If you like, I can send you an access to a development-site, where you can see the "wrong" behaviour of J3.6.0 (with no other changes)...
just drop me a line at it-solutions at schultz dot ch
I just installed J3.6.0-rc2 - and VOILA, everything works as expected.
So one of the bugfixes between J3.6.0-rc1 and J3.6.0-rc2 actually SOLVED the issue!
I am closing this, though I will investigate what bugfix is responsible for this ...