Author |
Message |
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Tue Jun 15, 2010 3:20 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
JLA wrote: |
Is the code I posted from PHPBB in my last post current? |
Yes, but as you remarked, it's not a drop-in replacement, and some other bits of code around it need to be changed. _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Wed Jun 16, 2010 9:28 am Post subject: Re: Going from 1st to last page in forum sections |
|
|
Dog Cow
Wrote to you at the other place. It seems that this one thing is causing the white page but not quite sure why....
Code: |
$sql = 'SELECT *
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_list) . '
ORDER BY topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', topic_last_post_id '.$sql_sort_order;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
} |
I saw that you posted on PHPBB when you 1st discussed this
Quote: |
you'll also need to copy the sql_in_set() method from phpBB 3's database class and paste it into your mysql4.php file for 2.
|
You didn't really go into much detail about that so not clear on what you are speaking of here.
Thanks _________________ http://www.jlaforums.com |
|
Back to top |
|
|
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Thu Jun 17, 2010 3:25 am Post subject: Re: Going from 1st to last page in forum sections |
|
|
I believe he is referring to this:
Code: | function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
{
if (!sizeof($array))
{
if (!$allow_empty_set)
{
// Print the backtrace to help identifying the location of the problematic code
$this->sql_error('No values specified for SQL IN comparison');
}
else
{
// NOT IN () actually means everything so use a tautology
if ($negate)
{
return '1=1';
}
// IN () actually means nothing so use a contradiction
else
{
return '1=0';
}
}
}
if (!is_array($array))
{
$array = array($array);
}
if (sizeof($array) == 1)
{
@reset($array);
$var = current($array);
return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var);
}
else
{
return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')';
}
} |
|
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Thu Jun 17, 2010 9:58 am Post subject: Re: Going from 1st to last page in forum sections |
|
|
Acaria wrote: | I believe he is referring to this:
Code: | function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
{
if (!sizeof($array))
{
if (!$allow_empty_set)
{
// Print the backtrace to help identifying the location of the problematic code
$this->sql_error('No values specified for SQL IN comparison');
}
else
{
// NOT IN () actually means everything so use a tautology
if ($negate)
{
return '1=1';
}
// IN () actually means nothing so use a contradiction
else
{
return '1=0';
}
}
}
if (!is_array($array))
{
$array = array($array);
}
if (sizeof($array) == 1)
{
@reset($array);
$var = current($array);
return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var);
}
else
{
return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')';
}
} |
|
Where is this supposed to be placed? Could this be the reason that the query in the previous post is causing a white page? _________________ http://www.jlaforums.com |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Thu Jun 17, 2010 7:58 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
Ok, copied the sql_in_set function from dbal in phpbb3 to mysql4 in our db folder. Didn't know what to copy from mysql file in phpbb3 though.
Now no white page but getting this error
Quote: |
Could not obtain topic information
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY topic_type DESC, topic_last_post_id DESC' at
SELECT * FROM phpbb_topics WHERE topic_id IN () ORDER BY topic_type DESC, topic_last_post_id DESC
Line : 354
File : viewforum.php
|
_________________ http://www.jlaforums.com |
|
Back to top |
|
|
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Fri Jun 18, 2010 3:03 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
I don't know, really. I've never worked with phpBB3, so I can't really help you.
In all honesty, this seems like more work than it should be. This should be as simple as adding a query before the one that grabs the page. Something like:
Code: | $page_count_sql = "SELECT id FROM table_name";
if ( ceil(mysql_num_rows(mysql_query($page_count_sql))) / 2 >= $_GET['$url_variable'] ) {
Run the query with a DESC at the end of the ORDER
}
else {
Run the regular query
} |
Note that I did not look at any variables or table names as I'm in a rush, so make sure to change those if you want to test it out. |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Fri Jun 18, 2010 4:53 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
Acaria wrote: | I don't know, really. I've never worked with phpBB3, so I can't really help you.
In all honesty, this seems like more work than it should be. This should be as simple as adding a query before the one that grabs the page. Something like:
Code: | $page_count_sql = "SELECT id FROM table_name";
if ( ceil(mysql_num_rows(mysql_query($page_count_sql))) / 2 >= $_GET['$url_variable'] ) {
Run the query with a DESC at the end of the ORDER
}
else {
Run the regular query
} |
Note that I did not look at any variables or table names as I'm in a rush, so make sure to change those if you want to test it out. |
I've sent Dog Cow a message and still waiting for his reply _________________ http://www.jlaforums.com |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Thu Jun 24, 2010 3:48 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
We heard from Dog Cow and he said we needed to copy the sql_escape() section from phpbb3 to our mysql4 file in phpbb2
Did this and we are getting this error
Quote: |
Could not obtain topic information
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY topic_type DESC, topic_last_post_id DESC' at
SELECT * FROM phpbb_topics WHERE topic_id IN () ORDER BY topic_type DESC, topic_last_post_id DESC
Line : 340
File : viewforum.php |
We sent this info over and awaiting a reply. _________________ http://www.jlaforums.com |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Mon Jun 28, 2010 9:28 pm Post subject: Re: Going from 1st to last page in forum sections |
|
|
Ah success. Dog Cow got back w/us. We were missing this final sql function
Code: |
/**
* Function for validating values
* @access private
*/
function _sql_validate_value($var)
{
if (is_null($var))
{
return 'NULL';
}
else if (is_string($var))
{
return "'" . $this->sql_escape($var) . "'";
}
else
{
return (is_bool($var)) ? intval($var) : $var;
}
}
|
Now everything is working perfectly and we were able to remove the limit on the page variable.
We're lovin it - especially on those 70,000 + page forum sections
Excellent and big thanks to Dog Cow! _________________ http://www.jlaforums.com |
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Tue Jun 29, 2010 9:22 am Post subject: Re: Going from 1st to last page in forum sections |
|
|
Nice job!
Congrats! _________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Sat Jul 03, 2010 1:54 am Post subject: Re: Going from 1st to last page in forum sections |
|
|
dogs and things wrote: | Nice job!
Congrats! |
Thanks and again big thanks to Dog Cow _________________ http://www.jlaforums.com |
|
Back to top |
|
|
|