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


PHP mysql::getInstance方法代码示例

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


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

示例1: __construct

 public function __construct($table)
 {
     header('Content-type:text/html;chartset=utf-8');
     $config_db = config('db');
     $this->table = $config_db['db_table_prefix'] . $table;
     $this->db = mysql::getInstance($config_db);
 }
开发者ID:im286er,项目名称:SimplePHP,代码行数:7,代码来源:model.php

示例2: init

 protected function init()
 {
     $this->_dbh = mysql::getInstance();
     $results = $this->_dbh->select('blog_users', ['username' => $this->username]);
     $this->id = $results[0]['id'];
     $this->create_time = $results[0]['create_time'];
     $this->email = $results[0]['email'];
     $this->avatar = $results[0]['avatar'];
     $this->user_group = $results[0]['user_group'];
 }
开发者ID:ztaoge,项目名称:blog,代码行数:10,代码来源:user.php

示例3: check_username

function check_username()
{
    $dbh = mysql::getInstance();
    $username = $dbh->select('blog_users', ['username' => $_GET['username']]);
    if ($username) {
        //该用户已存在
        echo 201;
    } else {
        //该用户不存在
        echo 404;
    }
}
开发者ID:ztaoge,项目名称:blog,代码行数:12,代码来源:signup.php

示例4: test

 public function test()
 {
     $this->_dbh = mysql::getInstance();
     return self::$results = $this->_dbh->select($this->_table, [], [], 'create_time', 'DESC');
 }
开发者ID:ztaoge,项目名称:blog,代码行数:5,代码来源:page.php

示例5: isset

<?php

require 'vendor/mysql.php';
require 'common/config/conf.php';
isset($_POST['username']) ? $username = $_POST['username'] : ($username = null);
isset($_POST['passwd']) ? $passwd = $_POST['passwd'] : ($passwwd = null);
if ($username && $passwd) {
    $dbh = mysql::getInstance();
    if ($result = $dbh->select('blog_users', ['username' => $username, 'passwd' => $passwd])) {
        setcookie('username', $username, COOKIE_EXPIRE);
        // 10s
        echo 'success';
    } else {
        echo 'fail';
    }
}
开发者ID:ztaoge,项目名称:blog,代码行数:16,代码来源:signin.php

示例6: error_reporting

<?php

error_reporting(0);
include 'simple_html_dom.php';
include 'mysql.class.php';
define('ENV', 'debug');
$config = ['charset' => 'utf8', 'db' => 'test', 'table' => 'films', 'debug' => ['host' => 'localhost', 'user' => 'user', 'password' => 'password', 'port' => '3306']];
$mysql = mysql::getInstance();
$mysql->connect($config);
for ($parm = 0; $parm <= 225; $parm += 25) {
    $url = 'http://movie.douban.com/top250?start=' . $parm . '&filter=&type=';
    $html = file_get_contents($url);
    $dom = new simple_html_dom($html);
    $listData = $dom->find('#content .item');
    foreach ($listData as $key => $val) {
        $film = ['title' => rtrim($val->find(".title", 0)->plaintext), 'subtitle' => str_replace(['&nbsp', ';/;'], '', $val->find(".title", 1)->plaintext), 'link' => $val->find("img", 0)->parent->attr['href'], 'img' => $val->find("img", 0)->src, 'rate' => $val->find('.star em', 0)->plaintext, 'quote' => $val->find(".quote .inq", 0)->plaintext];
        $mysql->data($film)->add();
        echo $film['title'] . ' -- ' . $film['quote'] . PHP_EOL;
    }
}
//
开发者ID:highestgoodlikewater,项目名称:filmSpider,代码行数:21,代码来源:top250.php

示例7: isset

<?php

require_once 'asset/smarty-3.1.28/libs/Smarty.class.php';
require_once 'common/config/conf.php';
require_once 'vendor/mysql.php';
require_once 'vendor/page.php';
require_once 'common/smarty.inc.php';
isset($_COOKIE['username']) ? $username = $_COOKIE['username'] : ($username = null);
if (is_null($username)) {
    $smarty->display('error.html');
} else {
    $users = mysql::getInstance()->select('blog_users', ['username' => $username]);
    $comments = mysql::getInstance()->select('blog_comments', ['comment_author' => $username]);
    $posts = mysql::getInstance()->select('blog_posts', ['post_author_id' => intval($users[0]['id'])]);
    $friends = mysql::getInstance()->select('blog_friends', ['user_id' => intval($users[0]['id'])]);
    $smarty->assign('posts', $posts);
    $smarty->assign('friends', $friends);
    $smarty->assign('comments', $comments);
    $smarty->assign('users', $users);
    $smarty->assign('username', $username);
    $smarty->display('user.tpl');
}
开发者ID:ztaoge,项目名称:blog,代码行数:22,代码来源:user.php

示例8: isset

<?php

require_once 'asset/smarty-3.1.28/libs/Smarty.class.php';
require_once 'common/config/conf.php';
require_once 'vendor/mysql.php';
require_once 'vendor/page.php';
require_once 'common/smarty.inc.php';
isset($_COOKIE['username']) ? $username = $_COOKIE['username'] : ($username = null);
//每页默认数据量
$num = 5;
$username = mysql::getInstance()->select('blog_users', ['username' => $username]);
$posts = mysql::getInstance()->select('blog_posts', ['post_author_id' => intval($username[0]['id'])]);
$page = new page('blog_posts', [], $num, 'create_time');
isset($_GET['page']) ? $p = $_GET['page'] : ($p = 1);
$list = $page->getPage($p);
$smarty->assign('list', $list);
$smarty->assign('page', $p);
$smarty->assign('tag', $page->getTag($p));
$smarty->assign('total', $total = $page->tt());
$smarty->assign('username', $username[0]['username']);
//$smarty->assign();
if ($username) {
    $smarty->display('postlist.tpl');
}
开发者ID:ztaoge,项目名称:blog,代码行数:24,代码来源:postlist.php


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