User Tools

Site Tools


php:sqldo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
php:sqldo [2015/03/20 09:14]
biggi
php:sqldo [2015/08/15 22:56] (current)
Line 1: Line 1:
 +<file php sqldo.php>​
 +function sqldo($query,​ $howparse = "",​ $querydb = ""​) {
 +// DB change for the query?
 +        if (!empty($querydb)) {
 +                $retvar = mysql_db_query($querydb,​ $query) or die("​x203 - "​.mysql_error());​
 +        } else {
 +// Otherwise just do the query
 +                $retvar = mysql_query($query) or die("​x203 - "​.mysql_error());​
 +        } 
  
 +// Parse the query as requested (if requested :P)
 +        if ($howparse == "​fetch_array"​) {
 +                $rows = array();
 +                while ($row = mysql_fetch_assoc($retvar)) {
 +                        $rows[] = $row;
 +                }
 +                if (!empty($rows)) {
 +                        return $rows;
 +                } else {
 +                        return;
 +                }
 +        } else if ($howparse == "​fetch_assoc"​) {
 +                return mysql_fetch_assoc($retvar);​
 +        }
 +
 +        return $retvar;
 +}
 +</​file>​