While it appears I'm unable to get any satisfactory answers concerning my last question posted here, I'm now looking to complete my project using MySQL instead of SQLite as my database background in a simple localhost environment. The one thing I need to accomplish is using a user defined function (UDF) which PHP can handle nicely with SQLite using the following code in an UPDATE query:
function nPoints($n1, $n2, $n3, $n4)
{
$numb = array($n1, $n2, $n3, $n4);
sort($numb);
return $numb[0] * 1 + $numb[1] * 2 + $numb[2] * 3 + $numb[3] * 4;
}
Essentially I am taking 4 numbers and doing a calculation which multiplies the smallest number by 1, then next smallest by 2, 3rd smallest by 3, and then the largest by 4 regardless if there are any ties or not. can I do this likewise as a MySQL user-defined function, and if not then what's the cleanest way without doing things the trickier way such as quick sort logic using for-next loops and such?
If PHP can handle registering such user-defined functions like it can with SQLite that would be better actually but how?