11
kahumbu
Re: quotes module
  • 2004/3/9 15:10

  • kahumbu

  • Documentation Writer

  • Posts: 277

  • Since: 2003/8/23


I used hsalazar's hack for a while and I noticed that sometimes quotes appear blank. I checked it and it seems the hack doesn't work if you deleted quotes, and thus resulting in non-existing id's in the 'citas' table. The count(*) = id syntax would not reach the end of the id list.

I tried my hand at solving the problem and would appreciate comments.

One solution came out like this:
Quote:

function random_quote_show() {
global $xoopsDB;
$block = array();
$texto = "";
$result = $xoopsDB -> query("SELECT id FROM ".$xoopsDB -> prefix('citas')." ORDER BY id DESC LIMIT 1");
list($endid) = $xoopsDB -> fetchRow($result);
$show = rand (1, $endid);
while ($texto == "") {
$result2 = $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix('citas')." WHERE id=".$show);
list($texto, $autor)= $xoopsDB->fetchRow($result2);
}
$block['texto']=$texto;
$block['autor']=$autor;
return $block;
}

But after testing offline, it had a good chance of 'timing out' MySQL queries if you have a lot of holes in the id column.

To work around this, I changed it to:

Quote:

function random_quote_show() {
global $xoopsDB;
$block = array();
$result = $xoopsDB -> query("SELECT id FROM ".$xoopsDB -> prefix('citas')." ORDER BY id DESC LIMIT 1");
list($endid) = $xoopsDB -> fetchRow($result);
$show = rand (1, $endid);
$result2 = $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix('citas')." WHERE id=".$show);
list($texto, $autor)= $xoopsDB->fetchRow($result2);
if ($texto == "") {
$result2 = $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix('citas')." WHERE id=".$endid);
list($texto, $autor)= $xoopsDB->fetchRow($result2);
}
$block['texto']=$texto;
$block['autor']=$autor;
return $block;
}

This second is not exactly a good solution since it just resorts to using the last quote in place of a 'missing' quote, but it works for now.

I hope others would come up with a better solution. This module is great and I hope it gets updated. In the future, I would like the option to activate/deactivate some quotes.

Thanks!

12
dtguy
Re: quotes module
  • 2004/3/22 20:44

  • dtguy

  • Just popping in

  • Posts: 2

  • Since: 2004/3/21


Great module, I do have one complaint however. I like putting movie quotes on my site, and it seems that it cuts the quote if the quote is too long. Is there an option I can change to increase the length of the quote so it isn't truncated?

Thank you for your time!

13
khchung
Re: quotes module
  • 2004/3/25 2:57

  • khchung

  • Just popping in

  • Posts: 3

  • Since: 2003/7/24


The database field that holds the text is limited to 255 characters. You may change the type of the field 'texto' from VARCHAR to TEXT which can hold much more text.

The operation can be done with phpMyAdmin.

14
khchung
Re: quotes module
  • 2004/3/25 6:12

  • khchung

  • Just popping in

  • Posts: 3

  • Since: 2003/7/24


I'd like to know whether this module is still under development? Some to-do mentioned in the module announcement are so nice that I am really wish to see them get implemented.

Login

Who's Online

235 user(s) are online (153 user(s) are browsing Support Forums)


Members: 0


Guests: 235


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits