本文整理汇总了PHP中dbConnect::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP dbConnect::connect方法的具体用法?PHP dbConnect::connect怎么用?PHP dbConnect::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbConnect
的用法示例。
在下文中一共展示了dbConnect::connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dbConnect
function __construct()
{
require_once 'dbConnect.php';
// opening db connection
$db = new dbConnect();
$this->conn = $db->connect();
}
示例2: dirname
/**
* constructor
**/
function __construct()
{
require_once dirname(__FILE__) . '/dbConnect.php';
//Open DB connection
$db = new dbConnect();
$this->conn = $db->connect();
}
示例3: dirname
function __construct()
{
require_once dirname(__FILE__) . '/dbConnect.php';
$db = new dbConnect();
//Connect to database
$this->con = $db->connect();
//Select "friends" collection, already defined in config.php
$this->col = new MongoCollection($this->con, DB_COLLECTION);
}
示例4: createTable
function createTable($name, $query)
{
$db = new dbConnect();
global $conn;
$result = mysqli_query($db->connect(), "create table if not exists {$name}({$query})");
if (!$result) {
die('failed to connect [' . $conn->connect_error . ']');
}
echo "Table '{$name}' created already.<br>";
}
示例5: dbConnect
<?php
/************************************************************
DEPENDENCIES
************************************************************/
require '../../settings.php';
/************************************************************
AJAX REQUEST
************************************************************/
$postdata = file_get_contents("php://input");
$dataobject = json_decode($postdata);
$post_id = $dataobject->id;
$post_status = $dataobject->status;
$post_title = $dataobject->title;
$post_date = $dataobject->date;
$post_content = $dataobject->input;
/************************************************************
DATABASE CONNECTION
************************************************************/
$connection = new dbConnect();
$pdo = $connection->connect();
/************************************************************
QUERY
************************************************************/
$querystring = "UPDATE posts SET post_status = :post_status, post_title = :post_title, post_date = :post_date, post_content = :post_content WHERE id = :post_id";
$preparedstatement = $pdo->prepare($querystring);
$preparedstatement->execute(["post_status" => $post_status, "post_title" => $post_title, "post_date" => $post_date, "post_content" => $post_content, "post_id" => $post_id]);
echo true;
示例6: 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;
}
}