Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Common PHP Mistakes Beginners often make

Avatar for Giorgi Giorgi
February 05, 2016

Common PHP Mistakes Beginners often make

Laravel Meetup Georgia 2016 #1 Speech

Avatar for Giorgi

Giorgi

February 05, 2016

Other Decks in Technology

Transcript

  1. Using mysql extension 1 $c = mysql_connect("host", "user", "pass"); 2

    mysql_select_db("db"); 3 $res = mysql_query("SELECT * FROM tb LIMIT 1"); 4 $row = mysql_fetch_assoc($result); 1 $mysqli = new mysqli("host", "user", "pass", "db"); 2 $res = $mysqli->query("SELECT * FROM tb LIMIT 1"); 3 $row = $res->fetch_assoc(); Deprecated! Secure Reliable Fast
  2. Not Using PDO 1 $sth = $dbh->prepare 2 ('SELECT *

    FROM fruit WHERE foo < ? AND bar = ?'); 3 $sth->execute(array(150, 'baz')); 4 $bazs = $sth -> fetchAll(); • Practical OOP Syntax • Support of PostgreSQL, MS SQL, etc. • Can Inject fetched data directly into a new object