ketting00 — 2013-11-15T08:36:00-05:00 — #1
When I start my website with a user log in system. I offer every user free 20mb data storage.
Now I want to upgrade the default value to 100mb and affect every user. How do I do that.
Here's the code:
$mysqli->query("CREATE TABLE `user` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 65 ) NOT NULL,
`email` VARCHAR( 75 ) NOT NULL,
`password` VARCHAR( 65 ) NOT NULL,
`storage` SMALLINT NOT NULL default '20',
PRIMARY KEY ( `id` ),
) ENGINE = INNODB CHARACTER SET UTF8 COLLATE utf8_general_ci
or die("DB error!");
And what if in the future I offer them unlimited storage.
shaun — 2013-11-15T16:08:34-05:00 — #2
I don't know enough about MySQL, but is it not as easy as changing the "default '20' " to "default '100' " ?
Failing that, and sorry if that was a ridiculous suggestion, I think you could set it using PHPMyAdmin too. I think you could edit the database table to add the default you want to that field.
felgall — 2013-11-15T16:44:47-05:00 — #3
Yes - the mySQL command to do that is:
ALTER TABLE `user` ALTER COLUMN `storage` SET DEFAULT '100';
Of course that only affects future new users. You'd still need to run a regular table update for the existing users.
ketting00 — 2013-11-16T20:51:30-05:00 — #4
Thanks for your help.
@ Shaun(OfTheDead) Any suggestion is better than never.