mysql - PHP branching optimization and efficiency -
i've come across problems numerous times , have had feeling it's not efficient logic , can't seem find straight answer:
in event of needing check database based on criteria, , update record if match true, while moving on different statement if match false, , inserting new record if database matches come false, there more efficient way optimize current branching?
$id = *first query id* //returns null if no match if (is_null($_id)) { #no match $id = *fallback query looking id *; -->returns null if no match } if (is_null($id)) {#still no match $id = *last fallback query looking id*; -->returns null if no match } if (is_null($id)) { # no match found, doesn't exist in db insert //code insert new record } else { #match found //code update record* }
have looked using replace into?
Comments
Post a Comment