当前位置: 首页>>代码示例>>PHP>>正文


PHP connect::connection方法代码示例

本文整理汇总了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>";
     }
 }
开发者ID:RajeshPerro,项目名称:student_kpi,代码行数:22,代码来源:rajesh_model.php

示例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);
开发者ID:RajeshPerro,项目名称:student_kpi,代码行数:31,代码来源:atten_controller.php

示例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.";
//}
开发者ID:ImtiH,项目名称:BAPWD,代码行数:27,代码来源:dbconnect.php


注:本文中的connect::connection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。