php - MySQLi equivalent of mysql_result()? -


i'm porting old php code mysql mysqli, , i've ran minor snag.

is there no equivalent old mysql_result() function?

i know mysql_result() slower other functions when you're working more 1 row, lot of time have 1 result , 1 field. using lets me condense 4 lines 1.

old code:

if ($r && mysql_num_rows($r))       $blarg = mysql_result($r, 0, 'blah'); 

desired code:

if ($r && $r->num_rows)       $blarg = $r->result(0, 'blah'); 

but there no such thing. :(

is there i'm missing? or going have suck , make everything:

if ($r && $r->num_rows)   {       $row = $r->fetch_assoc();       $blarg = $row['blah'];   } 

php 5.4 supports function array dereferencing, means can this:

if ($r && $r->num_rows)   {       $row = $r->fetch_assoc()['blah'];   } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -