News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Inserting posts using createPost

Started by kai920, December 13, 2009, 03:29:13 AM

Previous topic - Next topic

Arantor

Well, those are the two big places you'll need to concentrate on. I don't think the queries are that far different either.

kai920

#81
OK, I'll take a look at those later.

I'm trying to do the conversion now on my live server, but I'm getting a "No database selected" error.

Do I need to set $ssi_db_user or something?

NM, doing mysql_select_db worked.

kai920

I made 2 changes to ssi_recentPosts, so my portal recent posts block is working now:

Code (find) Select
// Let's restrict the query boys (and girls)
$query_where = '
m.id_msg >= {int:min_message_id}
' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . '


Code (replace) Select
// Let's restrict the query boys (and girls)
$query_where = (empty($exclude_boards) ? '' : '
b.id_board NOT IN ({array_int:exclude_boards})') . '






Code (find) Select
return ssi_queryPosts($query_where, $query_where_params, $num_recent, 'm.id_msg DESC', $output_method, true);


Code (replace) Select
return ssi_queryPosts($query_where, $query_where_params, $num_recent, 'm.poster_time DESC', $output_method, true);



Essentially, get rid of the m.id_msg limitation, and sort it by poster_time instead of id_msg.

Do you see an easier or better way? Will my edits affect parts of SMF negatively in some other way?

kai920

And for Sources/Recent.php, starting approx line 237:

Code (find) Select

$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : ''). '
AND m.id_msg >= {int:max_id_msg}';


Code (replace) Select

$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '');



SELECT m.id_msg
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
WHERE ' . $query_this_board . '
AND m.approved = {int:is_approved}
ORDER BY m.id_msg DESC


SELECT m.id_msg
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
WHERE ' . $query_this_board . '
AND m.approved = {int:is_approved}
ORDER BY m.poster_time DESC


kai920

Finally, Subs-Recent.php: (for forum index recent posts under Info Center)

Code (find) Select
WHERE m.id_msg >= {int:likely_max_msg}' .
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.id_msg DESC



Code (replace) Select
WHERE ' .
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
b.id_board != {int:recycle_board}' : '') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.poster_time DESC

Arantor

Removing the cap on id_msg will limit performance since it deliberately doesn't inspect the entire message table for performance reasons. In time it would be advisable to replace the id_msg WHERE clause.

kai920

Ah, good point. Maybe by the time SMF 2.0 final is released I can go back to the original way of sorting messages :)

I just noticed when browsing the forum as a guest, the simple portal frontpage block doesn't sort properly. Time to do more digging............

kai920

Marking this as solved. Big Huge thanks to you Arantor for guiding me every step of the way! Hopefully won't have to dig this thread up anymore, but you never know :)

Advertisement: