I am researching on the use of MySQLi and I have seen many articles, but each one always has some particularities about the pattern of development, my question anyone already set a default? For example something that can be followed with best practices?
For example, an embed code for this article here: PHP MySqli Basic usage (select, insert & update)
real_escape_string('P1234').'"'; $product_name = '"'.$mysqli->real_escape_string('42 inch TV').'"'; $product_price = '"'.$mysqli->real_escape_string('600').'"'; //MySqli Insert Query $insert_row = $mysqli->query("INSERT INTO products (product_code, product_name, price) VALUES($product_code, $product_name, $product_price)"); if($insert_row){ print 'Success! ID of last inserted record is : ' .$mysqli->insert_id .'
'; }else{ die('Error : ('. $mysqli->errno .') '. $mysqli->error); } ?>
And in this other article: How to Use PHP Improved MySQLi extension
$v1="'" . $conn->real_escape_string('col1_value') . "'"; $sql="INSERT INTO tbl (col1_varchar, col2_number) VALUES ($v1,10)"; if($conn->query($sql) === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); } else { $last_inserted_id = $conn->insert_id; $affected_rows = $conn->affected_rows; }