本文整理汇总了PHP中dbConnect::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP dbConnect::disconnect方法的具体用法?PHP dbConnect::disconnect怎么用?PHP dbConnect::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbConnect
的用法示例。
在下文中一共展示了dbConnect::disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertIntoTable
/**
* Creating new record
*/
public function insertIntoTable($obj, $column_names, $table_name)
{
$db = new dbConnect();
$this->conn = $db->connect();
$c = (array) $obj;
$keys = array_keys($c);
$columns = '';
$values = '';
foreach ($column_names as $desired_key) {
// Check the obj received. If blank insert blank into the array.
if (!in_array($desired_key, $keys)) {
${$desired_key} = '';
} else {
${$desired_key} = $c[$desired_key];
}
$columns = $columns . $desired_key . ',';
$values = $values . "'" . ${$desired_key} . "',";
}
$query = "INSERT INTO " . $table_name . "(" . trim($columns, ',') . ") VALUES(" . trim($values, ',') . ")";
$r = $this->conn->query($query) or die($this->conn->error . __LINE__);
if ($r) {
$new_row_id = $this->conn->insert_id;
$db->disconnect();
return $new_row_id;
} else {
$db->disconnect();
return NULL;
}
}