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


PHP MYSQL::connect方法代码示例

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


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

示例1: stimulate

 public function stimulate(&$hash)
 {
     $db = new MYSQL();
     $db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS, self::DB_DBNAME);
     @mysql_query("SET NAMES 'UTF8'");
     //must have a string parameter 'action'
     LINB::checkArgs($hash, array('string' => array('action' => NULL)));
     //handle the process
     switch ($hash->action) {
         case 'getlist':
             return $db->query("select `key`,`value` from `tbl_test`");
         case 'update':
             //must have string parameters 'key' and 'value'
             LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
             $db->update("tbl_test", array("key" => $hash->key, "value" => $hash->value), "`key`='" . $hash->key . "'");
             return 'ok';
         case 'delete':
             //must have a string parameter 'key'
             LINB::checkArgs($hash, array('string' => array('key' => NULL)));
             $db->delete("tbl_test", "`key`='" . $hash->key . "'");
             return 'ok';
         case 'create':
             //must have string parameters 'key' and 'value'
             LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
             $db->insert("tbl_test", array("key" => $hash->key, "value" => $hash->value));
             return 'ok';
     }
 }
开发者ID:esironal,项目名称:crossui,代码行数:28,代码来源:DBProcess.php

示例2: stimulate

 public function stimulate(&$hash)
 {
     $db = new MYSQL();
     $db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS);
     @mysql_query("SET NAMES 'UTF8'");
     //must have a string parameter 'action'
     LINB::checkArgs($hash, array('string' => array('action' => NULL)));
     //handle the process
     switch ($hash->action) {
         case 'listdbs':
             return $db->listdbs();
         case 'listtables':
             LINB::checkArgs($hash, array('string' => array('dbname' => NULL)));
             return $db->listtables($hash->dbname);
         case 'list':
             LINB::checkArgs($hash, array('string' => array('dbname' => NULL, 'tablename' => NULL, 'page' => 1, 'count' => 20)));
             $db->selectdb($hash->dbname);
             $count = $db->query("select count(*) from " . $hash->tablename);
             $table = $db->query("select * from " . $hash->tablename . " where 1 limit " . ($hash->page - 1) * 20 . ", " . $hash->count, true);
             return array($count, $table);
     }
 }
开发者ID:notchent,项目名称:linb,代码行数:22,代码来源:DBProcess.php

示例3: execute

 /**
  * Executes a mysql query and returns the results as an array of associative
  * arrays of column/value pairs of rows that match the query.
  * @param string The query string
  * @return array The rows that match the query.
  */
 private function execute($query)
 {
     if ($this->type == 'mysql') {
         require "../private/helpers/MYSQL.php";
         MYSQL::connect($this->host, $this->user, $this->password, $this->name);
         return MYSQL::query($query);
     }
 }
开发者ID:keyanmca,项目名称:Octopus,代码行数:14,代码来源:DBProxy.php


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