longjohn Posted November 1, 2021 Share Posted November 1, 2021 Hello. This is the current code: $table = 'core_members'; $query = \IPS\Db::i()->select('*', $table, 'name=' . "'$username'")->query; $result = \IPS\Db::i()->query($query)->fetch_assoc(); and then i can use $id = $result["member_id"]; // member id to get the member id of the username i entered. However, how do i change the member id? I can get the member id by using the code above of the user i want, but i want to be able to change it. Please help with that. To clarify, i can get the values i want, but i want to be able to change them as well. Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/ Share on other sites More sharing options...
ginerjm Posted November 1, 2021 Share Posted November 1, 2021 What kind of code is this? I do not recognize your syntax. Is this from some framework perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591634 Share on other sites More sharing options...
Barand Posted November 1, 2021 Share Posted November 1, 2021 39 minutes ago, longjohn said: but i want to be able to change it No, you really don't. That is path to disaster in a relational database where entities are related by their ids. As a rule, don't change, delete or re-use ids. Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591635 Share on other sites More sharing options...
Phi11W Posted November 1, 2021 Share Posted November 1, 2021 1 hour ago, longjohn said: However, how do i change the member id? Why do feel the you want to do this? Whatever the reason, it's almost certainly misguided. As Barand said, the unique identifier for each record should be generated when that record is created and should then persist, unchanged, until that record (and all the other records related to it) are finally and forever deleted. Can you imagine the chaos if your bank renumbered all of its accounts every time someone else closed their account? Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591636 Share on other sites More sharing options...
gizmola Posted November 1, 2021 Share Posted November 1, 2021 7 hours ago, ginerjm said: What kind of code is this? I do not recognize your syntax. Is this from some framework perhaps? This is manipulation of the Invision(company that makes our forum, which was formerly known as IPBoard) framework for doing things with Invision community (the suite of stuff that includes what was once IPboard). Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591664 Share on other sites More sharing options...
gizmola Posted November 1, 2021 Share Posted November 1, 2021 7 hours ago, longjohn said: Hello. This is the current code: $table = 'core_members'; $query = \IPS\Db::i()->select('*', $table, 'name=' . "'$username'")->query; $result = \IPS\Db::i()->query($query)->fetch_assoc(); Changing something is fairly trivial, but as this hits close to home for us, what exactly is it that you are trying to do, and why? Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591665 Share on other sites More sharing options...
ginerjm Posted November 1, 2021 Share Posted November 1, 2021 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/#findComment-1591666 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.