so, it's very kind to help me to understand (sorry for my english, i'm
french)

for rand(), i'm agree; But my problem is to have for example 5 pages in the
return of perhaps 50.
tag extension : <liste articles nombre=5 />

page_random is not possible, because if i want 5, the code could find only
one (page_ramdom just limit of the last for example)

So 50 pages is not heavy, and rand() is possible.

But i find always the same with :

[...]

array(
'ORDER BY' => 'rand()',
'LIMIT' => ($nombre+1)
),
Perhaps cache ?
But i put in LocalSettings.php : NO_CACHE

yonnel


2016-07-30 18:44 GMT+02:00 Bartosz Dziewoński <[email protected]>:

> You have to do it like this:
>
>     'ORDER BY' => 'rand()',
>
> Note that 'rand()' is in quotes, to send this string to MySQL and call the
> SQL rand() function – otherwise, you'd call the rand() function in PHP and
> send a random number to MySQL.
>
> In general this is a bad idea, though, since this doesn't mean "select a
> random row and return it" – it means "select all rows, order them randomly,
> then return the first one", which is going to quickly become slow if you
> have more than a couple thousand of rows.
>
> The page_random column John suggested in used for MediaWiki's built-in
> random page functionality, and a much better idea. You would use something
> like:
>
>     'page_random >= ' . wfRandom(),
>
> …in the WHERE condition. See how it's used in MediaWiki:
>
> https://phabricator.wikimedia.org/diffusion/MW/browse/master/includes/specials/SpecialRandompage.php;4de667f3c2dd2fea0f246a313a9ed848a793ed2f$116
>
>
> --
> Bartosz Dziewoński
>
>
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>



-- 
adresse mail :   [email protected]
mobile :           07 61 72 79 12

Identifiant de société : Siren : 501 161 384
 Code NAF : 722C
 Siret : 501 161 384 00018
 Code Insee : C75017862440
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to