MeekroDB biblioteka do zapytań SQL w PHP

04:30 0 Comments

www.meekro.com Classic Select Standard PHP forces you to remember to escape every variable. Don't drop any quotes or forget any escapes, or you're in trouble!
$mysqli->query("SELECT * FROM login WHERE username='"
  . $mysqli->real_escape_string($username) . "' AND password='"
  . $mysqli->real_escape_string($password) . "'");
MeekroDB takes care of quotes and escaping for you.
DB::query("SELECT * FROM login WHERE username=%s AND password=%s", $username, $password);
Large Update or Insert Standard PHP forces you to count the column names yourself to make sure everything goes into the right field. Don't forget to escape all strings, too, if you don't want to get hacked!
$mysqli->query("INSERT INTO mytable (`name`, `rank`, `location`, `age`, `intelligence`) 
  VALUES ('" . $mysqli->real_escape_string($name) . "','"
  . $mysqli->real_escape_string($rank) . "','"
  . $mysqli->real_escape_string($location) . "',"
  . intval($age) . ",'"
  . $mysqli->real_escape_string($intelligence) . "')");
MeekroDB lets you INSERT with a very simple format. You can tell at a glance if everything is right.
DB::insert('mytable', array(
  'name' => $name,
  'rank' => $rank,
  'location' => $location,
  'age' => $age,
  'intelligence' => $intelligence
));
Grab One Row or Field Standard PHP makes it a pain to grab the contents of a single MySQL field.
$result = $mysqli->query("SELECT COUNT(*) FROM accounts");
$row = $result->fetch_assoc();
$number_accounts = $row['COUNT(*)'];
MeekroDB makes it trivial.
$number_accounts = DB::queryFirstField("SELECT COUNT(*) FROM accounts");
If you want to grab a row, that's trivial too.
$account = DB::queryFirstRow("SELECT * FROM accounts WHERE username=%s", 'Joe');

ziomyslaw

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.

0 komentarze: