So, I have this database class in PHP, and I have only one function (except __constructand __destruct). Let me explain further ...
I originally wrote this when I connected to the database, I just call my function connect_to_db(), which will return a mysqli object. Then I used the function objects ( ->query(), ->prepare(), ->bind_param()etc.) to do anything. This is cluttered (and still such that I haven't switched my code to my new class yet) with a lot of functions that just do certain things, for example:
function get_country_info($db, $usrid) {
$statement = "select `name`, `population`, `money`, `food` from `countries` where `usr_id` = ?";
$qry = $db->prepare($statement) or
trigger_error("get_country_info():statement failed...");
$qry->bind_param("i", $usrid);
$qry->execute();
$qry->bind_result($name, $population, $money, $food);
$qry->fetch();
$res = array("name" => $name,
"pop" => $population,
"money" => $money,
"food" => $food);
return $res;
}
, , , , , - , mysqli ( ) . $db->close();, script , .
; query(). . eval(). , , , , , eval() ; ?
, , , ( ), , . , " " - , , , , - ( ) PHP,
, , . , - ?
: http://pastebin.org/353721, ~ 60 , . ( , , , -), , , , , .
.