我正在研究PHP上的OOP概念,这是一个名为'connect'的类,它连接到数据库并在数据库中插入请求_
class connect(){
public function insert($column, $value)
{
$insert = mysqli_query($this->con, "INSERT INTO $tablename ($column)
VALUES ('$value')");
}/* end of insert method */
}/* end of class 'connect' */
Run Code Online (Sandbox Code Playgroud)
我只是想知道,如果我每次通过为每个请求调用'insert'方法插入,是浪费时间还是浪费更多的服务器时间?或者我应该只做一个方法来插入所有请求at一次?
$call = new connect("localhost", "root", "", "facebook","fb1");
$call->insert("username", "testInsert141");
$call->insert("username", "testInsert141");
$call->insert("username2", "testInsert142");
$call->insert("username3", "testInsert143");
Run Code Online (Sandbox Code Playgroud)