Moneybag Posted March 30, 2015 at 10:01 PM Report Share #580526 Posted March 30, 2015 at 10:01 PM Boas Pessoal Qual dos seguintes códigos é mais "limpo"/eficiente na vossa opinião em mysqli : function get_employee($mysqli, $i_id) { $query = "SELECT * FROM tbl_employee WHERE id = '". $i_id ."'"; if($result = $mysqli->query($query)){ $row = $result->fetch_row(); } $result->close(); return $row; } function get_email($mysqli, $i_id) { if ($stmt = $mysqli->prepare("SELECT email FROM tbl_employee WHERE id = ? LIMIT 1")) { $stmt->bind_param('i', $i_id); $stmt->execute(); // Execute the prepared query. $stmt->store_result(); // get variables from result. $stmt->bind_result($db_email); $stmt->fetch(); } $stmt->close(); return $db_email; } Apesar das dua funcções retornarem diferentes tipos de dados , existem algo que possa melhorar em algum desses 2 códigos? Link to comment Share on other sites More sharing options...
Solution HappyHippyHippo Posted March 31, 2015 at 12:29 AM Solution Report Share #580541 Posted March 31, 2015 at 12:29 AM O uso de prepared statements é sempre preferencial. IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Moneybag Posted April 4, 2015 at 06:12 PM Author Report Share #580791 Posted April 4, 2015 at 06:12 PM HappyHippyHippo 👍 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now