Closed twiddly closed 8 years ago
hello @philip Please i need your help!!!! How can i add mysqli_result like @twiddly 's method in your project!! (..any idea!?) i have a huge php project full of mysql/ext!! it is impossible to handle this by doing one by one separately!! thank you
I assume you have some "include" php files (i.e., via include or require), so ideally you've got a common include file used by all the other files. Simply place the function above in that file so it's available everywhere. You'll also have to rename mysql_result to mysqli_result. I assume you have an editor that supports global replace in multiple files. If this doesn't work for you, I don't what else to suggest.
I'm a little hesitant to add function definitions to this migration script, but do understand the reasoning. There are wrappers out there (e.g., include 'mysql.php'; echo mysql_result(foo,bar);) that could be used as an alternative to actual migration, but I can't speak to how great they are. However, I'll compile a list of the ones I find, perform simple tests, and post the results here. As for mysql_result(), I'll think about that too. In the mean time, you can simply add a mysqli_result() definition in your function library.
This is considered fixed. It:
This works great, but if you use mysql_result there is no mysqli corollary for that. But... I found a nice alternative function here: http://mariolurig.com/coding/mysqli_result-function-to-match-mysql_result/
function mysqli_result($res,$row=0,$col=0){ $numrows = mysqli_num_rows($res); if ($numrows && $row <= ($numrows-1) && $row >=0){ mysqli_data_seek($res,$row); $resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res); if (isset($resrow[$col])){ return $resrow[$col]; } } return false; }