1
Shiva
Block weight not ordering correctly
  • 2009/7/17 20:12

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


One of my websites is not ordering the blocks correctly. This is the SQL:

le="color: #000000"><?php SELECT b . * FROM tbl_newblocks b, tbl_block_module_link m WHERE m.block_id = b.bid AND b.isactive =1 AND b.visible =1 AND m.module_id IN ( 0 , -1 ) AND b.bid IN ( 204, 203, 202, 201, 191, 192, 184, 185, 234, 172, 141, 140, 137, 138, 139, 136, 116, 153, 90, 89, 88, 91, 92, 67, 64, 56, 160, 159, 158, 157, 51, 50, 49, 48, 46, 45, 233, 230, 229, 228, 226, 208, 195, 190, 183, 39, 215, 214, 213, 212, 211, 22, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 232, 224, 223, 219, 210, 220, 200, 194, 193, 196, 198, 156, 155, 205, 154, 104, 103, 57, 58, 189, 218, 239 ) ORDER BY b.weight, b.bid LIMIT 0 , 30


The SQL works in the expected way, i.e. orders by weight when you remove the following part of the sql
le="color: #000000"><?php AND b.bid IN ( 204, 203, 202, 201, 191, 192, 184, 185, 234, 172, 141, 140, 137, 138, 139, 136, 116, 153, 90, 89, 88, 91, 92, 67, 64, 56, 160, 159, 158, 157, 51, 50, 49, 48, 46, 45, 233, 230, 229, 228, 226, 208, 195, 190, 183, 39, 215, 214, 213, 212, 211, 22, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 232, 224, 223, 219, 210, 220, 200, 194, 193, 196, 198, 156, 155, 205, 154, 104, 103, 57, 58, 189, 218, 239 )


Otherwise it seems to ignore the ordering by weight altogether.

Can someone shine some light on this? Its core XOOPS code. So hopefully some one else already has experience with this?

p.s.
This page may provide some pointers:
http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html

2
Shiva
Re: Block weight not ordering correctly
  • 2009/7/22 21:12

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


Any thoughts on this?

The symptom of this problems is that when a user is logged on the block order is displayed correctly but for anonymous user the blocks are the wrong order.


3
Shiva
Re: Block weight not ordering correctly
  • 2009/7/22 22:23

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


The following is the SQL for registered users (Which works fine; and it orders by weight):
le="color: #000000"><?php SELECT b . * FROM tbl_newblocks b, tbl_block_module_link m WHERE m.block_id = b.bid AND b.isactive =1 AND b.visible =1 AND m.module_id IN ( 0 , -1 ) AND b.bid IN ( 218, 204, 203, 202, 201, 191, 192, 188, 187, 186, 184, 185, 178, 170, 169, 168, 167, 166, 171, 172, 173, 165, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 137, 138, 139, 136, 116, 153, 90, 89, 88, 91, 92, 67, 64, 63, 62, 61, 60, 59, 56, 209, 160, 159, 158, 157, 51, 50, 49, 48, 46, 45, 233, 152, 44, 43, 42, 40, 39, 215, 214, 213, 212, 211, 22, 21, 20, 19, 18, 17, 234, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 232, 224, 223, 219, 210, 220, 200, 194, 193, 196, 198, 156, 155, 205, 154, 104, 103, 57, 58, 189, 231, 230, 229, 228, 226, 225, 195, 199, 239 ) ORDER BY b.weight, b.bid LIMIT 0 , 30


The following SQL is for anon users (this does not work, and order by bid but not weight for some reason!):
le="color: #000000"><?php SELECT b.* FROM tbl_newblocks b, tbl_block_module_link m WHERE m.block_id=b.bid AND b.isactive=1 AND b.visible=1 AND m.module_id IN (0,-1) AND b.bid IN (204,203,202,201,191,192,184,185,234,172,141,140,137,138,139,136,116,153,90,89,88,91,92,67,64,56,160,159,158,157,51,50,49,48,46,45,233,230,229,228,226,208,195,190,183,39,215,214,213,212,211,22,12,11,10,9,8,7,6,5,4,3,2,1,232,224,223,219,210,220,200,194,193,196,198,156,155,205,154,104,103,57,58,189,218,239) ORDER BY b.weight,b.bid



This is a mystery to me! It must be something to do with the "AND b.bid IN (" part of the SQL that makes it fail. But I don't know what or why!

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!