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


PHP database::connect方法代码示例

本文整理汇总了PHP中database::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP database::connect方法的具体用法?PHP database::connect怎么用?PHP database::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database的用法示例。


在下文中一共展示了database::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     parent::connect();
     // debug
     //parent::dump();
 }
开发者ID:robertbanh,项目名称:mrmilestone,代码行数:7,代码来源:dbFacade.php

示例2: __construct

 public function __construct()
 {
     //connect to the database if not connected
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
     //add multi-lingual support
     $language = new text();
     $text = $language->get();
     //get the ringback types
     $sql = "select * from v_vars ";
     $sql .= "where var_cat = 'Defaults' ";
     $sql .= "and var_name LIKE '%-ring' ";
     $sql .= "order by var_name asc ";
     $prep_statement = $this->db->prepare(check_sql($sql));
     $prep_statement->execute();
     $ringbacks = $prep_statement->fetchAll(PDO::FETCH_NAMED);
     unset($prep_statement, $sql);
     foreach ($ringbacks as $ringback) {
         $ringback = $ringback['var_name'];
         $label = $text['label-' . $ringback];
         if ($label == "") {
             $label = $ringback;
         }
         $ringback_list[$ringback] = $label;
     }
     $this->ringbacks = $ringback_list;
     unset($ringback_list);
     //get the default_ringback label
     /*
     $sql = "select * from v_vars where var_name = 'ringback' ";
     $prep_statement = $this->db->prepare(check_sql($sql));
     $prep_statement->execute();
     $result = $prep_statement->fetch();
     unset ($prep_statement, $sql);
     $default_ringback = (string) $result['var_value'];
     $default_ringback = preg_replace('/\A\$\${/',"",$default_ringback);
     $default_ringback = preg_replace('/}\z/',"",$default_ringback);
     #$label = $text['label-'.$default_ringback];
     #if($label == "") {
     	$label = $default_ringback;
     #}
     $this->default_ringback_label = $label;
     unset($results, $default_ringback, $label);
     */
     //get music on hold	and recordings
     if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/music_on_hold')) {
         require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
         $music = new switch_music_on_hold();
         $this->music_list = $music->get();
     }
     if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/recordings')) {
         require_once "app/recordings/resources/classes/switch_recordings.php";
         $recordings = new switch_recordings();
         $this->recordings_list = $recordings->list_recordings();
     }
 }
开发者ID:powerpbx,项目名称:fusionpbx,代码行数:60,代码来源:ringbacks.php

示例3: __construct

 public function __construct()
 {
     //connect to the database if not connected
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
     //set the application specific uuid
     $this->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
     //set the domain_uuid if not provided
     if (strlen($this->domain_uuid) == 0) {
         $this->domain_uuid = $_SESSION['domain_uuid'];
     }
     //get the voicemail_id
     if (!isset($this->voicemail_id)) {
         $sql = "select voicemail_id from v_voicemails ";
         $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
         $sql .= "and voicemail_uuid = '" . $this->voicemail_uuid . "' ";
         $prep_statement = $this->db->prepare(check_sql($sql));
         $prep_statement->execute();
         $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
         if (is_array($result)) {
             foreach ($result as &$row) {
                 $this->voicemail_id = $row["voicemail_id"];
             }
         }
         unset($prep_statement);
     }
 }
开发者ID:powerpbx,项目名称:fusionpbx,代码行数:31,代码来源:voicemail.php

示例4: login

 public function login()
 {
     $database = new database();
     if ($database->get_type() == 'mysql') {
         $db_arr = $database->connect();
         if ($db_arr[0] == 1) {
             return array(1, $db_arr[1]);
         }
         $this->db = $db_arr[1];
         // continue implementing login check
         $this->username = $this->db->escape_string(stripslashes($this->username));
         $this->password = $this->db->escape_string(stripslashes($this->password));
         $getuserquery = "SELECT * FROM user WHERE user_name='" . $this->username . "' AND user_password='" . $this->password . "'";
         $getuserresult = $this->db->query($getuserquery);
         $getuserresult_count = $getuserresult->num_rows;
         if ($getuserresult_count == 0) {
             $this->authstatus = false;
             return array(2, 'Username and password incorrect.');
         } elseif ($getuserresult_count == 1) {
             $this->authstatus = true;
             return array(0, $this->authstatus);
         } else {
             return array(2, 'MySQL returning weird things.');
         }
     } elseif ($database->get_type() == 'sqlite') {
         $db_arr = $database->connect_sqlite();
         $this->db = $db_arr;
         // do things that have yet to be decided
     }
 }
开发者ID:pluma-lms,项目名称:pluma-lms-php,代码行数:30,代码来源:user_login.php

示例5: upload

function upload($file_name, $file_type, $file_path, $file_title)
{
    if (!empty($_FILES["fileUpload"]) && !empty($_POST["imgTitle"])) {
        $file_type = $_FILES['fileUpload']['type'];
        $file_title = $_POST["imgTitle"];
        if ($file_type == "image/gif") {
            $file_path = $_FILES['fileUpload']['tmp_name'];
            $file_name = $_FILES['fileUpload']['name'];
            $new_path = "upload/img/" . $file_name;
            $file_error = $_FILES["fileUpload"]["error"];
            if ($file_error == 0 && move_uploaded_file($file_path, $new_path)) {
                $sql = "INSERT INTO gif.images (`title_img`, `name_img`, `id_user`) VALUES ('{$file_title}','{$file_name}', '0');";
                $upload = new database();
                $upload->connect();
                $query = $upload->query($sql);
                if (!empty($query)) {
                    $success = "Upload file và ghi dư liệu thành công.";
                    return $success;
                } else {
                    $success = "Upload file thành công.";
                    return $success;
                }
            }
            return $file_error;
        } else {
            $error = "File không đúng định dạng GIF";
            return $error;
        }
    }
}
开发者ID:lionlone,项目名称:gif,代码行数:30,代码来源:upload.php

示例6: database

 function __construct()
 {
     include_once 'class.database.php';
     $conn = new database();
     $this->link = $conn->connect();
     return $this->link;
 }
开发者ID:quinnd6,项目名称:php,代码行数:7,代码来源:class.ManageDatabase.php

示例7: adlib

function adlib($id, $type)
{
    // create adlib xml basic structure
    $XML = new simpleXmlElement("<?xml version='1.0' encoding='utf-8'?><adlibXML xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.adlibsoft.com/adlibXML.xsd' />");
    echoall("Start Adlib XML export");
    echoall("Connect database");
    $daba = new database();
    $daba->connect("localhost", "iggmp", "1s87J37r0");
    if ($daba->select("thesaurus")) {
        echoall("Database connected");
    } else {
        die("***ERROR - Database connection failed");
    }
    $termType = thesaurus::get_name($id);
    echoall("Starte bei <b>'" . thesaurus::get_name($id) . "'</b>");
    //------------------------------------------------------------------------------
    // create recordList
    xml_insert($XML, new simpleXmlElement("<recordList />"));
    // insert records in recordList
    $subXml = _subtree($id, $termType);
    if ($subXml) {
        xml_insert($XML->recordList, $subXml);
    }
    echoall("XML export completed<hr>");
    echoall($XML);
    return $XML->asXML();
}
开发者ID:nibble-arts,项目名称:openthesaurus,代码行数:27,代码来源:adlib.php

示例8: connect_2_db

function connect_2_db($cfg)
{
    if (!defined('NO_DSN')) {
        define('NO_DSN', FALSE);
    }
    if (strlen(trim($cfg['db_name'])) == 0) {
        echo '<span class="notok">Failed!</span><p />Database Name is empty';
        $db = null;
    } else {
        $db = new database($cfg['db_type']);
        @($conn_result = $db->connect(NO_DSN, $cfg['db_server'], $cfg['db_admin_name'], $cfg['db_admin_pass'], $cfg['db_name']));
        if ($conn_result['status'] == 0) {
            echo '<span class="notok">Failed!</span><p />Please check the database login details and try again.';
            echo '<br>Database Error Message: ' . $db->error_msg() . "<br>";
            $db = null;
        } else {
            if (!isset($cfg['db_type']) || strtolower($cfg['db_type']) == 'mysql') {
                // 20071103 - BUGID 771 eagleas
                $db->exec_query("SET CHARACTER SET utf8;");
                $db->exec_query("SET collation_connection = 'utf8_general_ci';");
            }
            echo "<span class='ok'>OK!</span><p />";
        }
    }
    return $db;
}
开发者ID:moraesmv,项目名称:testlink-code,代码行数:26,代码来源:migrate_16_to_17_functions.php

示例9: get_db

 public function get_db()
 {
     $database = new database();
     $dbtype = $database->get_type();
     if ($dbtype == 'mysql') {
         $db_arr = $database->connect();
         if ($db_arr[0] == 1) {
             return array(1, $db_arr[1]);
         }
         $this->db = $db_arr[1];
         $get_query = "SELECT * FROM user WHERE user_name='" . $this->username . "'";
         $get_result = $this->db->query($get_query);
         $get_result_arr = $get_result->fetch_assoc();
         $get_result_count = $get_result->num_rows;
         if ($get_result_count != 1) {
             return array(2, 'Name not found');
         }
     } elseif ($dbtype == 'sqlite') {
         $db_arr = $database->connect_sqlite();
         $this->db = $db_arr;
         // to be implemented
     }
     $this->id = $get_result_arr['user_id'];
     $this->username = $get_result_arr['user_name'];
     $this->email = $get_result_arr['user_email'];
     $this->groupname = $this->group_id_to_name($get_result_arr['user_group']);
     $this->firstname = $get_result_arr['first_name'];
     $this->middlename = $get_result_arr['middle_name'];
     $this->lastname = $get_result_arr['last_name'];
 }
开发者ID:pluma-lms,项目名称:pluma-lms-php,代码行数:30,代码来源:user.php

示例10: GetSQLValueString

 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
 {
     if (PHP_VERSION < 6) {
         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
     //$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexion , $theValue) : mysqli_escape_string( $conexion , $theValue);
     if (function_exist) {
         $obj = new database();
         $link = $obj->connect();
         $theValue = mysqli_real_escape_string($link, $theValue);
     }
     switch ($theType) {
         case "text":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "long":
         case "int":
             $theValue = $theValue != "" ? intval($theValue) : "NULL";
             break;
         case "double":
             $theValue = $theValue != "" ? doubleval($theValue) : "NULL";
             break;
         case "date":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "defined":
             $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue;
             break;
     }
     return $theValue;
 }
开发者ID:acronoxine,项目名称:movimientosSFA_V1,代码行数:31,代码来源:cat_categorias_md.php

示例11: database_connect

 public function database_connect()
 {
     $database = new database();
     $db_arr = $database->connect();
     if ($db_arr[0] == 1) {
         return array(1, $db_arr[1]);
     }
     $this->db = $db_arr[1];
 }
开发者ID:pluma-lms,项目名称:pluma-lms-php,代码行数:9,代码来源:vitals_connect.php

示例12: __construct

 public function __construct()
 {
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
     $this->domain_uuid = $_SESSION['domain_uuid'];
 }
开发者ID:powerpbx,项目名称:fusionpbx,代码行数:10,代码来源:switch_recordings.php

示例13: __construct

 /**
  * Called when the object is created
  */
 public function __construct()
 {
     //connect to the database if not connected
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
 }
开发者ID:kpabijanskas,项目名称:fusionpbx,代码行数:13,代码来源:xml_cdr.php

示例14: __construct

 public function __construct()
 {
     //connect to the database if not connected
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
     //set the default value
     $this->dialplan_global = false;
 }
开发者ID:powerpbx,项目名称:fusionpbx,代码行数:12,代码来源:dialplan.php

示例15: validateConnexion

function validateConnexion($user, $pass)
{
    $result = false;
    $db = new database();
    if ($db->connect()) {
        echo 'db connected <br>';
        if ($db->validateUser($user, $pass)) {
            $result = true;
        }
    }
    $db->disconnect();
    return $result;
}
开发者ID:xxdomxx,项目名称:GRV,代码行数:13,代码来源:function.php


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