cdmafra Posted September 13, 2013 Share Posted September 13, 2013 Hello. Is it possible to insert as default value in mysql the username of who is 'logged in' adding a article to the website? Independently of who is the user? Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/282126-default-value/ Share on other sites More sharing options...
requinix Posted September 13, 2013 Share Posted September 13, 2013 Not sure what the difference is between the "username of who is logged in" and the "user", but regardless: not really. You should do that manually in your SQL. Quote Link to comment https://forums.phpfreaks.com/topic/282126-default-value/#findComment-1449409 Share on other sites More sharing options...
cdmafra Posted September 13, 2013 Author Share Posted September 13, 2013 Not sure what the difference is between the "username of who is logged in" and the "user", but regardless: not really. You should do that manually in your SQL. It's the same thing. There are no ways to set it with a $_user variable or something like that? Quote Link to comment https://forums.phpfreaks.com/topic/282126-default-value/#findComment-1449418 Share on other sites More sharing options...
vinny42 Posted September 13, 2013 Share Posted September 13, 2013 It depends on what you mean by "the user". If you want the DEFAULT setting of a column to use a variable that only exists in PHP then obviously; no you can't do that, you will have to supply the username in your queries. There are systems that use a separate databaseuser for each website user and even they can't use the DEFAULT, but they can use a trigger to fetch the username and fill it in. Quote Link to comment https://forums.phpfreaks.com/topic/282126-default-value/#findComment-1449421 Share on other sites More sharing options...
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.