1.
I cant get ORDER BY to work properly. it gives different results in PHP and on direct query.
It orders properly on direct query but somewhat randomly when I query trough PHP.
This is the longest version of my query:
SELECT id,head,auth,date FROM news WHERE lang = 'sv' AND type = 'news' AND auth='public' OR lang = 'sv' AND type = 'news' AND auth='cust' OR lang = 'sv' AND type = 'news' AND auth='retail' OR lang = 'sv' AND type = 'news' AND auth='intern' ORDER BY id DESC
TIHIS IS THE PART OF THE SCRIPT.
<?
#Shall we get departmental news or news for all departments?
IF ($deptno > 0) $q= "lang = '$lang' AND type = 'news' and deptno = $deptno";
IF ((empty($deptno)) OR ($deptno == 0)) $q= "lang = '$lang' AND type = 'news'";
#What we show depends on who is asking.
#Everyone shall se public items.
IF ($svtstatus=="public") $statusq = "$q AND auth='public' ";
#Show public and customer items to customers.
IF ($svtstatus=="cust") $statusq = "$q AND auth='public' OR $q AND auth='cust'";
#show public,customer and retailers items to retailers.
IF ($svtstatus=="retail") $statusq = "$q AND auth='public' OR $q AND auth='cust' OR $q AND auth='retail'";
#show everything to our staff
IF ($svtstatus=="intern") $statusq = "$q AND auth='public' OR $q AND auth='cust' OR $q AND auth='retail' OR $q AND auth='intern'";
#paste it in with a select
$newsquery="SELECT id,head,auth,date FROM news WHERE $statusq";
#give language reference a new name
$newslang="$lang";
#some kind of homemade odbc-db2 LIMIT start value thing.
IF (empty($newsmin)) $newsmin = "0";
IF (empty($newsmax)) $newsmax = "5";
#Do the query and order it.
$listresult = odbc_do($connection,"$newsquery ORDER BY date DESC");
if ($listresult < 1) break;
#odbc_num_rows does nort seeme to work properly. This is a workaround.
$count="0";
while(odbc_fetch_row($listresult)) {
$count++;
}
#did we get anything?
IF ($count > 0) {
?>
<table border="0" cellpadding="4" cellspacing="0" <?if ((empty($deptno)) OR ($deptno==0)) print "class=border";?>>
<tr>
<td bgcolor="#<? print "$color1";?>">
<?
#If this is departmental news. Do the border thing.
if ((empty($deptno)) OR ($deptno==0)) print "<img src=http://www.phpbuilder.com/board/archive/index.php/\"gfx/smarutor1.gif\" width=\"200\" height=\"10\" border=\"0\">";?>
<br><b><?print "$dept9";?></b>
</TD>
</tr>
<tr bgcolor="#<?print "$color2";?>">
<td>
<?
print "<!--$newsquery ORDER BY date DESC -->";
#No LIMIT in db2. More stuff to cure that.
$countnewsmax="$newsmax";
IF ($newsmax > $count) $newsmax="$count";
for ($in=$newsmin; $in<$newsmax; $in++) {
odbc_fetch_row($listresult,$in);
$id = odbc_result($listresult,1);
$head = odbc_result($listresult,2);
$allow = odbc_result($listresult,3);
$date = odbc_result($listresult,4);
$made = strftime('%y-%m-%d',$date);
if (isset($deptno)) $plutt="../";
print "\n<P><img src=http://www.phpbuilder.com/board/archive/index.php/\"$plutt".
"gfx/$allow.gif\" width=\"10\" height=\"10\"> <a href=\"?visa=news&newsid=$id&newsmin=$newsmin&newsmax=$newsmax\"><i>$head</i></a>";
}
$nlessmax = $countnewsmax - 5;
$nlessmin = $newsmin - 5;
$newsmin = $newsmin + 5;
$newsmax = $countnewsmax + 5;
IF ($in > 5) print "<br><center><<<a href=\"/?newsmin=$nlessmin&newsmax=$nlessmax\">$less</a>";
IF ($count > $newsmin) print "<br> <a href=\"/?newsmin=$newsmin&newsmax=$newsmax\">$more</a>>></center><p>";
?>
2. Does db2 suck? It seemes to me to be slow, heavy and unforgiving. Some bugs in the PHP implimentation.
3. How do I adjust the amount of data allowed to be sent to the server. Now i get some error message when submitting quite moderate forms.
I cant get ORDER BY to work properly. it gives different results in PHP and on direct query.
It orders properly on direct query but somewhat randomly when I query trough PHP.
This is the longest version of my query:
SELECT id,head,auth,date FROM news WHERE lang = 'sv' AND type = 'news' AND auth='public' OR lang = 'sv' AND type = 'news' AND auth='cust' OR lang = 'sv' AND type = 'news' AND auth='retail' OR lang = 'sv' AND type = 'news' AND auth='intern' ORDER BY id DESC
TIHIS IS THE PART OF THE SCRIPT.
<?
#Shall we get departmental news or news for all departments?
IF ($deptno > 0) $q= "lang = '$lang' AND type = 'news' and deptno = $deptno";
IF ((empty($deptno)) OR ($deptno == 0)) $q= "lang = '$lang' AND type = 'news'";
#What we show depends on who is asking.
#Everyone shall se public items.
IF ($svtstatus=="public") $statusq = "$q AND auth='public' ";
#Show public and customer items to customers.
IF ($svtstatus=="cust") $statusq = "$q AND auth='public' OR $q AND auth='cust'";
#show public,customer and retailers items to retailers.
IF ($svtstatus=="retail") $statusq = "$q AND auth='public' OR $q AND auth='cust' OR $q AND auth='retail'";
#show everything to our staff
IF ($svtstatus=="intern") $statusq = "$q AND auth='public' OR $q AND auth='cust' OR $q AND auth='retail' OR $q AND auth='intern'";
#paste it in with a select
$newsquery="SELECT id,head,auth,date FROM news WHERE $statusq";
#give language reference a new name
$newslang="$lang";
#some kind of homemade odbc-db2 LIMIT start value thing.
IF (empty($newsmin)) $newsmin = "0";
IF (empty($newsmax)) $newsmax = "5";
#Do the query and order it.
$listresult = odbc_do($connection,"$newsquery ORDER BY date DESC");
if ($listresult < 1) break;
#odbc_num_rows does nort seeme to work properly. This is a workaround.
$count="0";
while(odbc_fetch_row($listresult)) {
$count++;
}
#did we get anything?
IF ($count > 0) {
?>
<table border="0" cellpadding="4" cellspacing="0" <?if ((empty($deptno)) OR ($deptno==0)) print "class=border";?>>
<tr>
<td bgcolor="#<? print "$color1";?>">
<?
#If this is departmental news. Do the border thing.
if ((empty($deptno)) OR ($deptno==0)) print "<img src=http://www.phpbuilder.com/board/archive/index.php/\"gfx/smarutor1.gif\" width=\"200\" height=\"10\" border=\"0\">";?>
<br><b><?print "$dept9";?></b>
</TD>
</tr>
<tr bgcolor="#<?print "$color2";?>">
<td>
<?
print "<!--$newsquery ORDER BY date DESC -->";
#No LIMIT in db2. More stuff to cure that.
$countnewsmax="$newsmax";
IF ($newsmax > $count) $newsmax="$count";
for ($in=$newsmin; $in<$newsmax; $in++) {
odbc_fetch_row($listresult,$in);
$id = odbc_result($listresult,1);
$head = odbc_result($listresult,2);
$allow = odbc_result($listresult,3);
$date = odbc_result($listresult,4);
$made = strftime('%y-%m-%d',$date);
if (isset($deptno)) $plutt="../";
print "\n<P><img src=http://www.phpbuilder.com/board/archive/index.php/\"$plutt".
"gfx/$allow.gif\" width=\"10\" height=\"10\"> <a href=\"?visa=news&newsid=$id&newsmin=$newsmin&newsmax=$newsmax\"><i>$head</i></a>";
}
$nlessmax = $countnewsmax - 5;
$nlessmin = $newsmin - 5;
$newsmin = $newsmin + 5;
$newsmax = $countnewsmax + 5;
IF ($in > 5) print "<br><center><<<a href=\"/?newsmin=$nlessmin&newsmax=$nlessmax\">$less</a>";
IF ($count > $newsmin) print "<br> <a href=\"/?newsmin=$newsmin&newsmax=$newsmax\">$more</a>>></center><p>";
?>
2. Does db2 suck? It seemes to me to be slow, heavy and unforgiving. Some bugs in the PHP implimentation.
3. How do I adjust the amount of data allowed to be sent to the server. Now i get some error message when submitting quite moderate forms.