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


PHP DbConnect::getInstance方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $db = DbConnect::getInstance();
     $this->conn = $db->getConnection();
     if (!$this->conn) {
         throw new Exception("cannot connect to server");
     }
     return $this->conn;
 }
开发者ID:anb1990,项目名称:assignment-api,代码行数:9,代码来源:Operations.php

示例2: backupDbTwToken

function backupDbTwToken($database_info, $create_tw_token_table_stmt)
{
    global $docroot;
    //get data base connection;
    $link = getInstance();
    $command = "SET NAMES 'utf8'";
    $stmt = mysqli_prepare($link, $command);
    mysqli_stmt_execute($stmt);
    $command = "select count(*) from tw_token";
    if ($stmt = mysqli_prepare($link, $command)) {
        //mysqli_stmt_bind_param($stmt, 'i', $wid);
        mysqli_stmt_execute($stmt);
        //mysqli_stmt_store_result($stmt);
        mysqli_stmt_bind_result($stmt, $total_row_count);
        mysqli_stmt_fetch($stmt);
    }
    mysqli_stmt_close($stmt);
    $link = DbConnect::getInstance();
    $command = "SET NAMES 'utf8'";
    $stmt = mysqli_prepare($link, $command);
    mysqli_stmt_execute($stmt);
    echo "total row count- tw_token: ", $total_row_count;
    $total_row_count = 20;
    $chunk_size = 10;
    $offset = 0;
    $data = '';
    $data .= $database_info;
    $data .= $create_tw_token_table_stmt;
    $timestamp = date("Y_m_d_H_i_s");
    $link = DbConnect::getInstance();
    while ($offset < $total_row_count) {
        $command = "select tid, user_id_hash, oauth_token, oauth_token_secret, oauth_verifier, user_id, \n\t\t\t                   screen_name, name, location, description, user_image_url, created\n\t \t\t\t\t\tfrom tw_token order by created asc limit {$offset}, {$chunk_size}";
        if ($stmt = mysqli_prepare($link, $command)) {
            //mysqli_stmt_bind_param($stmt, 'i', $wid);
            mysqli_stmt_execute($stmt);
            //mysqli_stmt_store_result($stmt);
            mysqli_stmt_bind_result($stmt, $tid, $user_id_hash, $oauth_token, $oauth_token_secret, $oauth_verifier, $user_id, $screen_name, $name, $location, $description, $user_image_url, $created);
            $screen_name = mysqli_real_escape_string($link, $screen_name);
            $name = mysqli_real_escape_string($link, $name);
            $location = mysqli_real_escape_string($link, $location);
            $description = mysqli_real_escape_string($link, $description);
            $data .= " insert ignore into tw_token(tid, user_id_hash, oauth_token, oauth_token_secret, oauth_verifier, user_id, \n\t\t\t                   screen_name, name, location, description, user_image_url, created ) values ";
            while (mysqli_stmt_fetch($stmt)) {
                $id = empty($id) ? 0 : $id;
                $tid = empty($tid) ? 0 : $tid;
                $data .= "({$tid}, '{$user_id_hash}', '{$oauth_token}', '{$oauth_token_secret}', '{$oauth_verifier}', {$user_id}, \n\t\t\t\t                          '{$screen_name}', '{$name}', '{$location}', '{$description}', '{$user_image_url}', '{$created}'),";
            }
            $data = substr($data, 0, -1);
            $data .= ";\n";
        } else {
            echo "<br>error";
        }
        $offset = $offset + $chunk_size;
    }
    //file_put_contents ( "db_backup_$timestamp.txt", $data, FILE_APPEND );
    file_put_contents($docroot . "/backup_db/backup_db_tw_token_{$timestamp}.sql", $data);
    //file_put_contents('junk.sql','test');
    //file_put_contents ( "backup_db_tw_token.sql", $data);
    echo "--end";
    mysqli_stmt_close($stmt);
    return;
}
开发者ID:raj4126,项目名称:twextra,代码行数:62,代码来源:backup_db_cli.php

示例3: __construct

 public function __construct()
 {
     $this->conn = DbConnect::getInstance()->connectDb();
 }
开发者ID:ToogleLiu,项目名称:too,代码行数:4,代码来源:DbBase.class.php


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