Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/14/2021 in all areas

  1. A more efficient way is to only select the 8 rows you're looking for instead of selecting the entire table.
    2 points
  2. Add "limit 8" to your query.
    1 point
  3. The Item class should be responsible solely for the logic of an item. It should not have anything to do with determining what webpage was accessed, nor should it do anything with creating HTML markup. Those are responsibilities for other code.
    1 point
  4. Your foreach loop will run to completion (ie, print every row) before your while loop condition gets re-evaluated. In pseudo-code, what you wrote is this: while $counter < 8 for each result $row print $row increment $counter end end Where as what you want to write, is while $counter < 8 fetch next result $row if $row exists print $row end increment $counter end There are multiple ways to write that. One way is to fetch a row at a time rather than everything. Another is to fetch it all like you are now, but break; after the 8th row.
    1 point
  5. These are the results I get (wordlist contains 351,100 records) $t1 = microtime(1); $res = $db->query("SELECT word FROM wordlist WHERE MATCH (word) AGAINST ('sang*' IN BOOLEAN MODE)"); $t2 = microtime(1); printf('Query 1 : %0.4f seconds<br>', $t2 - $t1); $t1 = microtime(1); $res = $db->query("SELECT word FROM wordlist WHERE word LIKE 'sang%'"); $t2 = microtime(1); printf('Query 2 : %0.4f seconds<br>', $t2 - $t1); results (74 words found) Query 1 : 0.0026 seconds Query 2 : 0.0005 seconds
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.