Jump to content

MySQLi código mais eficiente?


Go to solution Solved by HappyHippyHippo,

Recommended Posts

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();
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.

    // get variables from result.
   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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.