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 revisionPrevious revision
php:sqldo [2015/03/20 09:14] biggiphp:sqldo [2015/08/15 22:56] (current) – external edit 127.0.0.1
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>
php/sqldo.txt · Last modified: 2015/08/15 22:56 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki