note 105446 added to function.mysql-query
| From: | seingh at patronum dot tk | Date: | Thu, 18 Aug 2011 18:08:14 +0000 |
| Subject: | note 105446 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182575@lists.php.net to get a copy of this message | ||
usefully function to use insend of mysql_query:
<?php
$mysql_last_query = ""; //this var contains the last mysql query
function query($sql, $args) { #sintax: query("query", "arg1", "arg2",
"argn"); EXAMPLE: query("select * from %s", $_GET["table"]);
global $mysql_last_query;
$args = func_get_args();
if(($num = func_num_args()) > 1)
$sql = call_user_func_array("sprintf", $args);
$mysql_last_query = $sql;
return mysql_query($sql);
}
function select($table, $what = "*", $where = "", $limit = ""){ #this
function is a "shortcut" for mysql select EXAMPLE: select("blah"); //SELECT *
FROM blah and so on
return mysql_query("SELECT ".$what." FROM ".$table.($where == "" ?
"":(" WHERE ".$where)).($limit == "" ? "":(" LIMIT
".$limit)));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 188.97.172.244
----
Manual Page -- http://www.php.net/manual/en/function.mysql-query.php
Edit -- https://master.php.net/note/edit/105446
Del: integrated -- https://master.php.net/note/delete/105446/integrated
Del: useless -- https://master.php.net/note/delete/105446/useless
Del: bad code -- https://master.php.net/note/delete/105446/bad+code
Del: spam -- https://master.php.net/note/delete/105446/spam
Del: non-english -- https://master.php.net/note/delete/105446/non-english
Del: in docs -- https://master.php.net/note/delete/105446/in+docs
Del: other reasons-- https://master.php.net/note/delete/105446
Reject -- https://master.php.net/note/reject/105446
Search -- https://master.php.net/manage/user-notes.php