ramesh
ramesh

Reputation: 4082

PHP max length of an array

What is the max length of an PHP array .. My requirement is

There are about 4000 movies in my database and there are so many users , now 1500 ( increasing) . Each member can rate the movie only once.

So I made a row in my user table that will store in which movies user rated. I m saving that in the following format

user_id   |  rated_films
-----------------------------------------
12        |  1111,1025,3541,2354,1584,3691,2451

Each time when an user hit of rating button I will check with this column ..

Is it the correct way. And I am wondering if I made a separate table for this rating like

user_id  |  Film_id
---------------------
12       |  10245
12       |  20145

Is thhis will hang the process of the application ? Suppose if all users will rate all the movies

Please help me with the correct code

Thanks

Upvotes: 0

Views: 814

Answers (2)

Ilion
Ilion

Reputation: 6872

Your second solution is the way to go with a many-to-many relation table. The first solution is far to kludgey. It seems unlikely every user will rate every movie and your queries will probably be more contained anyway so it should be easy for mysql to handle this.

Upvotes: 1

StrongLucky
StrongLucky

Reputation: 588

I think there is no limit. The problem is the memory. you can edit the memory php is allowed to user in the php.ini. In my opionion you should not use an array for this task. It is a database task. If you need something in array you should use a limit.

Upvotes: 1

Related Questions