Hi,
I created a module A in Studio which must contain the result of a query on two other modules B and C
in view.list of module A I entered the query:
$db = DBManagerFactory :: getInstance();
$query = "SELECT B.data, C.name FROM B INNER JOIN C ON B.id = C.id_b";
$Result = $ db-> query($query);
but the query loops. If I do a simple query, like
SELECT data FROM B
it is OK.
Where am I wrong? Is it right to enter the query in view.list? It’s okay to use
DBManagerFactory and $ db-> query ($ query)?
Do you really have all those spaces between $ and the variable names? And around the ::?
That way it won’t work. But my guess is that you’re using Google Translate and that adds the spaces.
When you assign a variable you can inspect it’s value to know if the assignment worked. Use a debugger or output it’s value onto the screen or into the logs.
No no, the spaces have been added by google translate.
The problem is the query and the inner join, it takes a long time, continues to run. For this reason I was wondering if the way of acting is correct, is the use of
$ result = $ db-> query ($ query);
is the fact of having placed it in
view.list.php
Are using an IDE? Debugging through the code really helps.
If not, then use the log to output some information. This will help you know how often your query is running, for example. I don’t think single query would take long, you probably have some problem that it is getting run for every row or even for every field in the list view.
but it gives me this error:
Warning: Creating default object from empty value
Call to undefined method stdClass :: save ()
which is a known problem, we recommend that you enter:
if (! isset ($ module-> mbvardefs) || is_null ($ module-> mbvardefs)) {
$ module-> mbvardefs = new stdClass ();
}
but in my code it is already inserted.
So I disabled the display_errors in php.ini, but no saving is made and no error is shown on the screen, not even in suitecrm.log. The query is executed, because if I do echo $ row [‘id_activity’] inside the loop, it is shown