Home > Net >  Set the default address
Set the default address

Time:09-16

Ideas to address table to insert a data query and then write the address add_def user_id in a column in the table of 10000 the number of columns, and then judge if greater than zero, then modify the original data add_def 0

Finally realizes the effect in address add page access to add value, submitted to the process of judgment 'to set the default address is checked or not checked if checked (true) to insert the data from the database at the same time, the user id in the query table of 10000 did the original default address, if there are changes to the original user id in the table of 10000 add_def is zero, if you don't check the insert (add_def default is 0) directly

CodePudding user response:

Put a tag field, the address tag which address is the default address, as well,

CodePudding user response:

The address table structure should have to at least the following

Id addr uid isdefault

At the UI level will have a "whether to set the default address" checkbox.

If a user when add address, select the, and then execute

The update address set isdefault uid=uid=0 where

Insert the address values (... 1)

You can extend the optimization of course, if the database a also have no, even if he didn't choose the default address, you will also be set to the default address.

At the time of query orderby isdefault desc will first strip out...
  • Related