Is it just me or does this seem too simple? Would it work?
PHP Code:$ad = $DB_site->query ("select banner from banner);
$adbanner = = array_rand ($ad[banner], 1);
| SitePoint Sponsor |
Doesn't this do the same thing?PHP Code:$ad = $DB_site->query ("select banner from banner order by rand() limit 1);

hello, i just saw a minor error
isn't it ment tobe
PHP Code:$ad = $DB_site->query ("select banner from banner order by rand() limit 1");
Never looked for this at MySQL's documentation because well frankly everytime I did in the past, it just didn't have the functionality.Originally posted by Sketch
Doesn't this do the same thing?PHP Code:$ad = $DB_site->query ("select banner from banner order by rand() limit 1);
yeah...what alkaif said...whoops on the "
Yeah, Wayne, I think that should do the same thing and you make mysql do the work instead of php...always more desirable. Especially for vBulletin.
Aaron
Huh? You mean you were using a version of MySQL that didn't support it or you think it didn't work properly?Originally posted by W. Luke
Never looked for this at MySQL's documentation because well frankly everytime I did in the past, it just didn't have the functionality
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
No... I have found it easier to implement commen DBMS functionality in PHP than to wait for MySQL to have support for it so I don't bother looking. MySQL is great for simple queries but hell if you want to do anything sophisticated. Some of that should change with 4.0 but they need to increase functionality and stop worrying so much about speed. All the speed in the world is useless if you can't do the query to begin with.Originally posted by seanf
Huh? You mean you were using a version of MySQL that didn't support it or you think it didn't work properly?
Sean![]()
It's been there since 3.23.3
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
I think you are confused... This is one little function that I never needed before now. When I did need it, I didn't bother looking at MySQL's documentation because I could do it in PHP.
If MySQL had features like this a year ago (3.22 days) to make it a robust system instead of sacrificing all functionality for speed, I would have been a lot more eager to see if they supported it.
In my book the standard installation still doesn't support necessary features needed in a modern DBMS. Things like Views, Sub-Selects, Stored Procedures, Triggers, Foreign Key Support (Referential Integrity), Tablespaces (for disk management) and many more things. A version number of 3.XX implies a little longetivity and stability so features should be there. Don't get me wrong, raw speed is nice but unless you can utilize the system to do most of that work, it is worthless.
It did! I'm not sure exactly when it was added. Look at Kevin's post here from 09-Aug-2000Originally posted by W. Luke
If MySQL had features like this a year ago (3.22 days) to make it a robust system instead of sacrificing all functionality for speed, I would have been a lot more eager to see if they supported it
I do agree that a lot of things are missing, but what's there is there
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
The mySQL order by rand is great when you need to fetch large quantities of data and don't want to have to do 2 queries or load all the data into memory. It's actually quite efficient for things like picking random advertisments to show (with a small amount of data and a lot to gain by the reduced number queries).
Owen
Just for the record,
from my MySQL book (new riders) I read that:
As of MySQL 3.23.2, you can use ORDER BY RAND() to sort results randomly.
So as W.Luke said it was not available at 3.22 days.
pippo
SeanOriginally posted by seanf
It's been there since 3.23.3
Sean![]()
![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
sean,
I didn't read that...
mea culpa, mea culpa, mea maxima culpa
So my book confirm with the tollerance of 1 sub-subversion what you said!
pippo
Last edited by pippo; Nov 2, 2002 at 10:52.
Bookmarks