mysqli_query($ conn,$ sql)或$ conn-> query($ sql) [英] mysqli_query($conn, $sql) or $conn->query($sql)
问题描述
我是Web开发的新手,我目前未使用任何框架.
I am new to web Development, I am currently not using any frameworks.
到目前为止,我正在使用mysqli_query($conn, $sql)
将查询发送到MySQL服务器.
Till now, I was using mysqli_query($conn, $sql)
to send a query to the MySQL server.
最近我读了另一种使用$conn - > query($sql)
的技术.
Recently I read another technique which use $conn - > query($sql)
.
我知道$conn->query($sql)
是发送查询的OOP方法,而mysqli_query($conn, $sql)
是过程方法.
I know that $conn->query($sql)
is the OOP way of sending query and mysqli_query($conn, $sql)
is the procedural method.
我还没有学习过面向对象的PHP.但是,在进入框架之前,我将很快学习它.
I haven't learned Object Oriented PHP yet However, I am going to learn it soon before moving onto a framework.
有人可以告诉我使用$conn->query($sql)
优于mysqli_query($conn, $sql)
的优势吗?
它更安全吗?还有其他东西吗?
Could someone tell me the advantages of using $conn->query($sql)
over the mysqli_query($conn, $sql)
?
Is it more secure? Is there something else to it?
我知道OOP比程序性更好,但是我想从安全性(主要是)的角度了解主要优势!
I know OOP is better than Procedural, but I'd like to know the main advantages, from the point of Security(mainly)!
推荐答案
都不是.
弄清楚点有三点:
- 学习"没有太多意义.对象语法看起来很愚蠢:只是访问方法或属性的箭头.当然您已经走了.
-
第二个选项可以让您更少键入:
- There is noting much to "learn". The object syntax is as silly as it seems: just an arrow to access a method or a property. Surely you already go it.
Second option just gets you less typing:
mysqli_query($mysqli, $query);
vs.
$mysqli->query($query);
我知道OOP比程序更胜一筹
I know OOP is better than Procedural
这与这里无关.不要将面向对象编程与对象语法混淆.前者是一个非常复杂的主题,需要花费数年的时间才能学习,而且您几乎很快就会掌握它.尽管对象语法只是一种语法-多多少少也不少.没什么可担心的,也没有任何戏剧性的好处
This is just irrelevant here. Do not confuse Object Oriented Programming with object syntax. The former is a very complex topic, which takes years to learn and you are not nearly going to get it soon. While object syntax is just a syntax - no more no less. Nothing too complicated to worry about, nor any dramatical benefits either
这篇关于mysqli_query($ conn,$ sql)或$ conn-> query($ sql)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!