English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
mysqli_real_query() function executes a mysql query
mysqli_real_query()the function executes a single database query, whose results can be retrieved or stored using mysqli_store_result() or mysqli_use_result().
to determine whether the given query really returns a result set, you can view mysqli_field_count().
mysqli_real_query($con, $query)
序号 | canshu ji shuoming |
---|---|
1 | con (required) this is an object representing the connection with the MySQL Server. |
2 | query (required) this is a string value that represents the query to be executed. The data passed to this query should be properly escaped. |
this query returns a boolean value,ifif successful, thentrue; if failed, thenfalse.
this function was introduced in PHP version 5 and can be used in all higher versions.
dibian shiyan zhanshi lemysqli_real_query()hannu de yongfa (mianxiang guocheng shili)
<?php $con = mysqli_connect("localhost", "root", "password", "mydb"); mysqli_query($con, "CREATE TABLE IF NOT EXISTS my_team(ID INT, First_Name VARCHAR(255), Last_Name VARCHAR(255), Place_Of_Birth VARCHAR(255), Country VARCHAR(255))"); print("chuangjian biao ..."."\n"); //jiazai jilv dianru my_team biao mysqli_real_query($con, "insert into my_team values(1, 'Shikhar', 'Dhawan', 'Delhi', 'India')"); mysqli_real_query($con, "insert into my_team values(2, 'Jonathan', 'Trott', 'CapeTown', 'SouthAfrica')"); mysqli_real_query($con, "insert into my_team values(3, 'Kumara', 'Sangakkara', 'Matale', 'Srilanka')"); mysqli_real_query($con, "insert into my_team values(4, 'Virat', 'Kohli', 'Delhi', 'India')"); print("إدراج سجل ...\n"); //إغلاق الاتصال mysqli_close($con); ?>
نتائج الإخراج
إنشاء جدول ... إدراج سجل ...
في أسلوب البرمجة الموجهة بالأ象ص، نسيج هذه الوظيفة يكون$con->real_query();.إليك مثال على كيفية استخدام هذه الوظيفة في أسلوب البرمجة الموجهة بالأ象ص
<?php $con = new mysqli("localhost", "root", "password", "mydb"); //إدراج سجل في جدول players $con->query("CREATE TABLE IF NOT EXISTS players(First_Name VARCHAR(255), Last_Name VARCHAR(255), Country VARCHAR(255))"); $con->real_query("insert into players values('Shikhar', 'Dhawan', 'India')"); $con->real_query("insert into players values('Jonathan', 'Trott', 'SouthAfrica')"); print("إنشاء البيانات......"); //إغلاق الاتصال $res = $con -> close(); ?>
نتائج الإخراج
إنشاء البيانات......