different results in queries [message #624] |
Mon, 12 February 2007 19:44 |
stephenboey
Messages: 54 Registered: January 2007
|
Member |
|
|
Was trying to call mysql_query, mysql_fetch_array in _cm_post_updateRecord
Can this be done? Seems like calling those does not give me any results or error messages.
I went back to mysql functions because radicore does not give me the correct results. Attached is a script to implement Van Tulder's Tree http://www.sitepoint.com/print/hierarchical-data-database.
One version is using radicore and the other using his script.
Test data:
role_id role_id_snr lft rgt
GLOBAL NULL 1 10
TESTING GLOBAL 2 9
TESTING2 TESTING 3 8
TESTING3 TESTING2 4 7
TESTING4 TESTING3 5 6
Test Scenerio (Reparent TESTING2 to GLOBAL)
role_id role_id_snr lft rgt
GLOBAL NULL 1 10
TESTING GLOBAL 2 3
TESTING2 TESTING 4 9
TESTING3 TESTING2 5 8
TESTING4 TESTING3 6 7
-
Attachment: Script.txt
(Size: 2.07KB, Downloaded 859 times)
[Updated on: Mon, 12 February 2007 20:24] Report message to a moderator
|
|
|
|
|
Re: different results in queries [message #627 is a reply to message #626] |
Tue, 13 February 2007 09:16 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Yes, the output from _dml_getData() is an array which is indexed by row number, so $rowdata[0] would give you the first row and $rowdata[1] would give you the second row.
What you need to do is to print a trace from each of your two pieces of code to see exactly what sql query was issued and what results were returned. Only when you can compare the two traces will you be able to see where the dfference is.
You need to include the following lines somewhere in your code:
and
print_r($children_rowdata);
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Re: different results in queries [message #630 is a reply to message #629] |
Tue, 13 February 2007 20:36 |
stephenboey
Messages: 54 Registered: January 2007
|
Member |
|
|
like I said Tony print_r cannot display the contents because your framework redirects the page. This is absolutely not within my control.
I remarked out the calling of rebuild_tree, to eliminate any program logic related error.
As you can see in the csv file. There are two records with role_id_snr = 'GLOBAL'
SELECT SQL_CALC_FOUND_ROWS role_id FROM mnu_role WHERE role_id_snr='GLOBAL' ORDER BY mnu_role.role_id asc LIMIT 1 OFFSET 0 LOCK IN SHARE MODE=>Count=2 <**** in sql trace file
But the query only returns one, you can see this in the sql trace file.
SELECT SQL_CALC_FOUND_ROWS role_id FROM mnu_role WHERE role_id_snr='TESTING' ORDER BY mnu_role.role_id asc LIMIT 1 OFFSET 0 LOCK IN SHARE MODE=>Count=0
SELECT SQL_CALC_FOUND_ROWS role_id FROM mnu_role WHERE role_id_snr='' ORDER BY mnu_role.role_id asc LIMIT 1 OFFSET 0 LOCK IN SHARE MODE=>Count=0 <***** role_id_snr=''
-
Attachment: Feb14.zip
(Size: 2.09KB, Downloaded 1260 times)
[Updated on: Tue, 13 February 2007 20:37] Report message to a moderator
|
|
|
Re: different results in queries [message #631 is a reply to message #630] |
Wed, 14 February 2007 04:34 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Yes, it is in your control. You insert debugging statements into the code to display various details, then you exit() to stop further execution. This will stop any redirect which destroys your debug output.
Alternative you could try using the error_log() function to write all debugging text to a file instead of the browser.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: different results in queries [message #635 is a reply to message #634] |
Wed, 14 February 2007 09:47 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You're getting there, but you are still not doing as I originally asked. You need to provide a trace from each of the two different sets of code. You need to display the contents of each sql SELECT clause as well as the data that it returns. Then you can compare the traces from each of the two pieces of code to see where it is different.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: different results in queries [message #637 is a reply to message #636] |
Wed, 14 February 2007 10:50 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
No, it is not a bug. Each call to _dml_getData() causes the current setting of $this->rows_per_page to be used in the LIMIT clause. Your code appears to be running inside an UPDATE1 pattern, and if you look inside file 'std.update1.inc' you will see the line:
$dbobject->setRowsPerPage(1);
which tells the system to extract and display 1 record at a time. This setting is still in operation when your custom code is being executed. To remove all limits you must insert the following line before any calls to $this->_dml_getData():
$this->rows_per_page = 0;
Do not forget to reset it aferwards.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|