Re: [PHP] Re: Amount of data in the database
Hello again! Basically...you can't. What I meant was that when you insert the data into the table, you need to store the size as well. Consider the following table (called files): dataID user filename size filedata [int, autoincremented] [int] [varchar] [int] [blob] Now, let's say user 3 uploads the file 'airplane.jpg' to the server. We need to have the following information: $filename = The name of the file $filedata = The actual file $size = The size of the uploaded file You can find out about how to get these variables from http://www.php.net/manual/en/features.file-upload.php Then you insert the data into your table; "INSERT INTO files(user, filename, size, filedata) VALUES (3, $filename, $size, $filedata)" This means that every time some user upload a file, the size of the file will be tied to a particular record. Then you just use MySQLs built-in SUM function to find out the total amount of data (check my previous post) Kindly /Lars Olsson ([EMAIL PROTECTED]) Denis L. Menezes wrote: Thanks Lars. Sorry, then I have another question. How do I find the size of the record? Thanks Denis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Amount of data in the database
Thanks Lars. Sorry, then I have another question. How do I find the size of the record? Thanks Denis - Original Message - From: "Lars Olsson" <[EMAIL PROTECTED]> To: "Denis L. Menezes" <[EMAIL PROTECTED]> Cc: "PHP general list" <[EMAIL PROTECTED]> Sent: Tuesday, January 14, 2003 9:36 PM Subject: [PHP] Re: Amount of data in the database > A pretty easy way of doing it is to add a size field to the table. > Whenever you INSERT INTO or UPDATE the table, update this field to > contain the size of the data for the current record. Then, whenever you > need to check the amount of data for a particular user, just use this query: > > "SELECT SUM(size) FROM sometable WHERE user=someuser" > > Hope this helps > > > /Lars Olsson ([EMAIL PROTECTED]) > > PS. Ive done this in a file upload script I created a while ago. If you > want, I can mail you the relevant bits and bytes. DS. > > > > Denis L. Menezes wrote: > > Hello friends. > > > > I have a need for checking how much data(in kb) exists of each of the user members in the MySQL so that when they upload more data I can restrict/warn them of the amount of data they have on the server at present. > > > > can anyone please tell me how to check the amount of data on the mysql for each record? > > > > thanks very much > > Denis > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Amount of data in the database
A pretty easy way of doing it is to add a size field to the table. Whenever you INSERT INTO or UPDATE the table, update this field to contain the size of the data for the current record. Then, whenever you need to check the amount of data for a particular user, just use this query: "SELECT SUM(size) FROM sometable WHERE user=someuser" Hope this helps /Lars Olsson ([EMAIL PROTECTED]) PS. Ive done this in a file upload script I created a while ago. If you want, I can mail you the relevant bits and bytes. DS. Denis L. Menezes wrote: Hello friends. I have a need for checking how much data(in kb) exists of each of the user members in the MySQL so that when they upload more data I can restrict/warn them of the amount of data they have on the server at present. can anyone please tell me how to check the amount of data on the mysql for each record? thanks very much Denis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php