本文整理汇总了PHP中connect::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP connect::connection方法的具体用法?PHP connect::connection怎么用?PHP connect::connection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connect
的用法示例。
在下文中一共展示了connect::connection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DeleteData
public function DeleteData($users, $passwords, $dbName, $table, $id)
{
$con_user = $users;
$con_pass = $passwords;
$con_name = $dbName;
$connection_object = new connect();
if (!empty($con_user) && !empty($con_pass)) {
$dbcon = $connection_object->connection('localhost', $con_user, $con_pass, $con_name);
} else {
$dbcon = $connection_object->connection('localhost', 'firoz', 'firoz', $con_name);
}
$sql = "delete from {$table} where `id`={$id}";
//$query=mysql_query($sql);
$deleteStatement = $dbcon->prepare($sql);
if ($deleteStatement->execute(array(':id' => $id))) {
echo "<script> alert('তথ্যটি ডিলিট করা হয়েছে ।')</script>";
echo "<script>location.href='enter.php'</script>";
} else {
echo "<script> alert('আপনার ডিলিট করা সম্ভব হয়নি ।')</script>";
echo "<script>location.href='enter.php'</script>";
}
}
示例2: PDO
{
$this->host = $hostname;
$this->user = $username;
$this->pass = $passwoard;
$this->db = $database;
$connect = new PDO("mysql:host={$this->host};dbname={$this->db}", $this->user, $this->pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connect->setAttribute(PDO::ATTR_PERSISTENT, true);
return $connect;
}
}
$connection_object = new connect();
include 'database_config.php';
$db_user = $database_user;
$db_pass = $databse_pass;
$dbcon = $connection_object->connection('localhost', $db_user, $db_pass, 'student_kpi');
//start from here
$batch = $_POST['b_id'];
$group = $_POST['g_id'];
$student_id = $_POST['s_id'];
$std_names = $_POST['name'];
$att = $_POST['attendance'];
$en_date = $_POST['entry_date'];
$preparedStatement = $dbcon->prepare('INSERT INTO student_attendance (s_id, name, b_id, g_id, attendance, entry_date)
VALUES (:sid, :sname, :bid, :gid, :atten, :ent_date)');
$arrlength = count($student_id);
for ($x = 0; $x < $arrlength; $x++) {
$preparedStatement->bindParam(':sid', $student_id[$x]);
$preparedStatement->bindParam(':sname', $std_names[$x]);
$preparedStatement->bindParam(':bid', $batch);
$preparedStatement->bindParam(':gid', $group);
示例3: connection
<?php
class connect
{
var $host;
var $user;
var $pass;
var $db;
public $connect;
public function connection($hostname, $username, $passwoard, $database)
{
$this->host = $hostname;
$this->user = $username;
$this->pass = $passwoard;
$this->db = $database;
$connect = new PDO("mysql:host={$this->host};dbname={$this->db}", $this->user, $this->pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connect->setAttribute(PDO::ATTR_PERSISTENT, true);
return $connect;
}
}
$connection_object = new connect();
$dbcon = $connection_object->connection("localhost", "root", "", "database_name");
//if($dbcon)
//{
// echo "Connection establish succesfully.";
//}