Daron Posted July 6, 2011 Posted July 6, 2011 Hey MWG community i was just working on my register.php & started wondering would it be possible to substitute that super long query in register.php by just setting default values for all those columns. for example instead of using $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10)"); couldnt i just set the default value for all those as 10 then remove the query? if so i would do this to all the queries :cool: except ones like userid, name, & password. Quote
Maniak Posted July 7, 2011 Posted July 7, 2011 You could but you'd still have to have a Query there.. That being: $db->query('INSERT INTO `usersats` (`userid`) VALUES('.$i.')'); p.s. I haven't coded in a few months + I am tired so this may not work. (I haven't tested it either) Quote
Diesl Posted July 7, 2011 Posted July 7, 2011 in short: yes, but you still need the query to insert a new row for the user in your table. Quote
Nickson Posted July 9, 2011 Posted July 9, 2011 While you stlll need to run that query, as it is now. There are other options where you do not need to do that, like triggers and such, but I'm not sure how far all webhosts support that with mysql.. It is a lot easier, as you can see by yourself, by just typing "VALUES ( $i )" instead of typing every value. With using defaults you'll have a much smaller chance on making a mistake or forgetting a value. Some people also like to give a bonus during user registration to a certain value, be sure to add that value to the code, because if you don't, it will just use the default value if there is any set for that field. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.