• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MDB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Delete

 public function Delete($get)
 {
     if (isset($get['id']) && is_numeric($get['id'])) {
         $db = new MDB();
         $result = $db->deleteMovie($get['id']);
         if ($result) {
             header('Location: ./?message=delete-success');
         } else {
             header('Location: ./?message=delete-error');
         }
         exit;
     } else {
         header('Location: ./?message=request-error');
         exit;
     }
 }
开发者ID:arjaneising,项目名称:My-Movie-List,代码行数:16,代码来源:edit.php


示例2: Step2

 function Step2()
 {
     if (isset($_POST['movie-id']) && is_numeric($_POST['movie-id']) && isset($_POST['original-title']) && strlen($_POST['original-title']) > 1 && isset($_POST['english-title'])) {
         $db = new MDB();
         $success = $db->editTitles($_POST['movie-id'], $_POST['original-title'], $_POST['english-title']);
         if ($success) {
             header('Location: ' . WEB_ROOT . '?message=edit-titles-success');
         } else {
             header('Location: ' . WEB_ROOT . '?message=edit-titles-error');
         }
         exit;
     } else {
         header('Location: ' . WEB_ROOT . '?message=edit-titles-error');
         exit;
     }
 }
开发者ID:arjaneising,项目名称:My-Movie-List,代码行数:16,代码来源:edit-titles.php


示例3: token

 public function token($token)
 {
     $id = Model::factory('v1_tokens')->user($token);
     if ($id) {
         self::$user_id = MDB::objectId($id);
         return $this->get();
     }
 }
开发者ID:rhrn,项目名称:apirn,代码行数:8,代码来源:users.php


示例4: testSetDbInstanceDefault

 function testSetDbInstanceDefault()
 {
     $db =& MDB::connect(DB_DSN, $GLOBALS['DB_OPTIONS']);
     $qt =& new MDB_QueryTool();
     $qt->setDbInstance($db);
     $dbActual =& $qt->getDbInstance();
     $this->assertEqual($db->fetchmode, $dbActual->fetchmode);
 }
开发者ID:laiello,项目名称:coopcrucial,代码行数:8,代码来源:mdb_querytool_testDbInstance.php


示例5: test_default

 /**
  * Check if the two instances are the same by comparing
  * the fetchMode, since this is the easiest to compare if
  * two objects are the same in PHP4.
  * We can do that since the querytool sets the fetch mode to
  * MDB_FETCHMODE_ASSOC.
  * Not very nice but it works.
  *
  */
 function test_default()
 {
     $db =& MDB::connect(DB_DSN);
     $qt =& new MDB_QueryTool();
     $qt->setDbInstance($db);
     $dbActual =& $qt->getDbInstance();
     $this->assertEquals($db->fetchmode, $dbActual->fetchmode);
 }
开发者ID:laiello,项目名称:coopcrucial,代码行数:17,代码来源:SetDbInstance.php


示例6: remove

 public function remove($user, $id)
 {
     $remove = MDB::objectId($id);
     $remove['user_id'] = MDB::stringId($user);
     $x = $this->collection->remove($remove, array('safe' => true));
     if ($x['n']) {
         return $id;
     }
 }
开发者ID:rhrn,项目名称:apirn,代码行数:9,代码来源:tags.php


示例7: gen

 public function gen(array $user)
 {
     $id = MDB::stringId($user);
     $tail = base64_encode(hash('sha256', date('Y-m-d') . $id . $user["_id"]->getTimestamp() . $user["_id"]->getInc() . microtime()));
     self::$user_id = MDB::stringId($user);
     self::$token = $id . Model_V1_Tokens::DELIMETER . $tail;
     if ($this->add()) {
         return self::$token;
     }
 }
开发者ID:rhrn,项目名称:apirn,代码行数:10,代码来源:tokens.php


示例8:

 /**
  * Connects to the db
  *
  * @return object DB The database object
  * @access private
  */
 function &_db_Connect($dsn)
 {
     $this->_debugMessage('_db_Connect($dsn)');
     if (is_object($this->db)) {
         return $this->db;
     }
     $db =& MDB::connect($dsn);
     $this->_testFatalAbort($db, __FILE__, __LINE__);
     return $db;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:16,代码来源:MDB.php


示例9: Auth_Container_MDB

 function &getContainer()
 {
     static $container;
     #print "In MDBContainer::getContainer {$this->skip_tests}\n";
     if (!isset($container)) {
         include 'auth_container_mdb_options.php';
         $container = new Auth_Container_MDB($options);
         // Catch if DB connection cannot be made
         $res = $container->_prepare();
     }
     if (!MDB::isConnection($container->db)) {
         $this->markTestSkipped("MDB is not a connection object, check dsn");
     }
     return $container;
 }
开发者ID:klofac,项目名称:combros,代码行数:15,代码来源:MDBContainer.php


示例10: Auth_Container_MDB

 function &getContainer()
 {
     static $container;
     #print "In MDBContainer::getContainer {$this->skip_tests}\n";
     if (!isset($container)) {
         include './auth_container_mdb_options.php';
         $container = new Auth_Container_MDB($options);
         // Catch if DB connection cannot be made
         $res = $container->_prepare();
     }
     if (!MDB::isConnection($container->db)) {
         #print "In MDBContainer::getContainer container->db is error \n";
         $this->skip_tests = true;
         $this->skip_tests_message = "SKIP TEST:MDB is not a connection object, check dsn !!!";
     }
     return $container;
 }
开发者ID:BackupTheBerlios,项目名称:lesen-svn,代码行数:17,代码来源:MDBContainer.php


示例11: action_mongo

 public function action_mongo()
 {
     MDB::$config = Kohana::$config->load('database')->mongo;
     $config = MDB::config();
     #d::v($config);
     $mongo = MDB::mongo();
     d::v($mongo);
     $db = MDB::db();
     d::cl($db);
     $colle = MDB::collection('test');
     d::cl($colle);
     $data = array('data' => 'test');
     $insert = MDB::insert($data);
     d::v($insert);
     $find = MDB::find();
     d::cl($find);
     d::v(iterator_to_array($find));
     $gridFS = MDB::gridFS();
     d::cl($gridFS);
     $remove = MDB::remove();
     d::v($remove);
 }
开发者ID:rhrn,项目名称:apirn,代码行数:22,代码来源:test.php


示例12: elseif

    include "trailer.inc";
    exit;
}
if (!isset($search_pos) || $search_pos <= 0) {
    $search_pos = 0;
} elseif ($search_pos >= $total) {
    $search_pos = $total - $total % $search["count"];
}
# Now we set up the "real" query using LIMIT to just get the stuff we want.
$sql = "SELECT E.id, E.create_by, E.name, E.description, E.start_time, R.area_id\n        FROM mrbs_entry E, mrbs_room R\n        WHERE {$sql_pred}\n        AND E.room_id = R.id\n        ORDER BY E.start_time asc";
if ($debug_flag) {
    echo "<p>DEBUG: SQL: <tt> {$sql} </tt><BR>";
}
$types = array('integer', 'text', 'text', 'text', 'integer', 'integer');
$result = $mdb->limitQuery($sql, $types, $search_pos, $search["count"]);
if (MDB::isError($mdb)) {
    fatal_error(0, $result->getMessage() . "\n" . $result->getUserInfo() . "\n");
}
$num_records = $mdb->numRows($result);
$has_prev = $search_pos > 0;
$has_next = $search_pos < $total - $search["count"];
if ($has_prev || $has_next) {
    echo "<B>" . get_vocab("records") . ($search_pos + 1) . get_vocab("through") . ($search_pos + $num_records) . get_vocab("of") . $total . "</B><BR>";
    # display a "Previous" button if necessary
    if ($has_prev) {
        echo "<A HREF=\"search.php?search_str={$search_url}&search_pos=";
        echo max(0, $search_pos - $search["count"]);
        echo "&total={$total}&year={$year}&month={$month}&day={$day}\">";
    }
    echo "<B>" . get_vocab("previous") . "</B>";
    if ($has_prev) {
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:search.php


示例13: changePassword

 /**
  * Change password for user in the storage container
  *
  * @param string Username
  * @param string The new password (plain text)
  */
 function changePassword($username, $password)
 {
     $this->log('Auth_Container_MDB::changePassword() called.', AUTH_LOG_DEBUG);
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') {
         $cryptFunction = 'strval';
     } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) {
         $cryptFunction = $this->options['cryptType'];
     } else {
         $cryptFunction = 'md5';
     }
     $password = $cryptFunction($password);
     $query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s", $this->options['final_table'], $this->options['final_passwordcol'], $this->db->getTextValue($password), $this->options['final_usernamecol'], $this->db->getTextValue($username));
     // check if there is an optional parameter db_where
     if ($this->options['db_where'] != '') {
         // there is one, so add it to the query
         $query .= " AND " . $this->options['db_where'];
     }
     $this->log('Running SQL against MDB: ' . $query, AUTH_LOG_DEBUG);
     $res = $this->query($query);
     if (MDB::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->code);
     }
     return true;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:34,代码来源:MDB.php


示例14: define

require_once 'PHPUnit/GUI/HTML.php';
define('DB_DSN', 'mysql://root@localhost/mdb_qt');
define('TABLE_USER', 'QueryTool_user');
define('TABLE_ADDRESS', 'QueryTool_address');
define('TABLE_QUESTION', 'question');
define('TABLE_ANSWER', 'answer');
$allTables = array(TABLE_USER, TABLE_ADDRESS, TABLE_QUESTION, TABLE_ANSWER);
require_once 'sql.php';
require_once 'UnitTest.php';
require_once 'Common.php';
//
//  common setup (this actually also does the tearDown, since we have the DROP TABLE queries in the setup too
//
$querytool = new tests_Common();
foreach ($dbStructure[$querytool->db->phptype]['setup'] as $aQuery) {
    if (MDB::isError($ret = $querytool->db->query($aQuery))) {
        //include_once 'Var_Dump.php';
        //var_dump::display($ret);
        die($ret->getUserInfo());
    }
}
//
//  run the test suite
//
require_once 'PHPUnit/GUI/SetupDecorator.php';
$gui = new PHPUnit_GUI_SetupDecorator(new PHPUnit_GUI_HTML());
$gui->getSuitesFromDir(dirname(__FILE__), '.*\\.php', array('UnitTest.php', 'Common.php', 'sql.php', 'index.php'));
$gui->show();
/*
require_once 'Get.php';
require_once 'GetAll.php';
开发者ID:laiello,项目名称:coopcrucial,代码行数:31,代码来源:index.php


示例15: ExecuteQuery

 public static function ExecuteQuery($sql)
 {
     $connection = DBConnectionManager::get_connection(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME);
     $db = MDB::cursor($connection, '');
     return $db->fetchObject($db->query($sql));
 }
开发者ID:alegalliard,项目名称:aug,代码行数:6,代码来源:Model.php


示例16: header

<?php

header("Content-type: text/javascript");
require_once '../_includes/main.php';
$db = new MDB();
$imdbIds = $db->getImdbIds();
echo 'Movies.config.imdbIds = "|';
if (isset($imdbIds) && !empty($imdbIds)) {
    foreach ($imdbIds as $id) {
        echo str_pad($id['id'], 7, '0', STR_PAD_LEFT) . '|';
    }
}
echo '";';
开发者ID:arjaneising,项目名称:My-Movie-List,代码行数:13,代码来源:imdb-top-250.js.php


示例17: init

 /**
  * Initialize the storage container
  *
  * @param array Array with the storage configuration
  * @return bool true on success, false on failure.
  *
  * @access public
  */
 function init($storageConf)
 {
     parent::init($storageConf);
     if (!MDB::isConnection($this->dbc) && !is_null($this->dsn)) {
         $this->options['optimize'] = 'portability';
         if ($this->function == 'singleton') {
             $dbc =& MDB::singleton($this->dsn, $this->options);
         } else {
             $dbc =& MDB::connect($this->dsn, $this->options);
         }
         if (PEAR::isError($dbc)) {
             $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $dbc->getMessage(), 'debug' => $dbc->getUserInfo()));
             return false;
         }
         $this->dbc =& $dbc;
     }
     if (!MDB::isConnection($this->dbc)) {
         $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'storage layer configuration missing'));
         return false;
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:30,代码来源:MDB.php


示例18: garbageCollection

 /**
  * Garbage collector.
  *
  * @param    int maxlifetime
  */
 function garbageCollection($maxlifetime)
 {
     $this->flushPreload();
     $query = 'DELETE FROM ' . $this->cache_table . ' WHERE (expires <= ' . time() . ' AND expires > 0) OR changed <= ' . time() - $maxlifetime;
     $res = $this->db->query($query);
     $query = 'SELECT sum(length(cachedata)) as CacheSize FROM ' . $this->cache_table;
     $cachesize = $this->db->getOne($query);
     if (MDB::isError($cachesize)) {
         return new Cache_Error('MDB::query failed: ' . $this->db->errorMessage($cachesize), __FILE__, __LINE__);
     }
     //if cache is to big.
     if ($cachesize > $this->highwater) {
         //find the lowwater mark.
         $query = 'SELECT length(cachedata) as size, changed FROM ' . $this->cache_table . ' ORDER BY changed DESC';
         $res = $this->db->query($query);
         if (MDB::isError($res)) {
             return new Cache_Error('MDB::query failed: ' . $this->db->errorMessage($res), __FILE__, __LINE__);
         }
         $numrows = $this->db->numRows($res);
         $keep_size = 0;
         while ($keep_size < $this->lowwater && $numrows--) {
             $entry = $this->db->fetchInto($res, MDB_FETCHMODE_ASSOC);
             $keep_size += $entry['size'];
         }
         //delete all entries, which were changed before the "lowwater mark"
         $query = 'DELETE FROM ' . $this->cache_table . ' WHERE changed<=' . ($entry['changed'] ? $entry['changed'] : 0);
         $res = $this->db->query($query);
         if (MDB::isError($res)) {
             return new Cache_Error('MDB::query failed: ' . $this->db->errorMessage($res), __FILE__, __LINE__);
         }
     }
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:37,代码来源:mdb.php


示例19: sql_syntax_caseless_contains

 if (!empty($creatormatch)) {
     $sql .= " AND" . sql_syntax_caseless_contains("e.create_by", $creatormatch);
 }
 if ($sortby == "r") {
     # Order by Area, Room, Start date/time
     $sql .= " ORDER BY 9,10,2";
 } else {
     # Order by Start date/time, Area, Room
     $sql .= " ORDER BY 2,9,10";
 }
 if ($debug_flag) {
     echo "<p>DEBUG: SQL: <tt> {$sql} </tt>\n";
 }
 $types = array('integer', 'integer', 'integer', 'text', 'text', 'text', 'text', 'timestamp', 'text', 'text');
 $res = $mdb->query($sql, $types);
 if (MDB::isError($res)) {
     fatal_error(0, $res->getMessage() . "\n" . $res->getUserInfo() . "\n");
 }
 $nmatch = $mdb->numRows($res);
 if ($nmatch == 0) {
     echo "<P><B>" . get_vocab("nothing_found") . "</B>\n";
     $mdb->freeResult($res);
 } else {
     $last_area_room = "";
     $last_date = "";
     echo "<P><B>" . $nmatch . " " . ($nmatch == 1 ? get_vocab("entry_found") : get_vocab("entries_found")) . "</B>\n";
     while ($row = $mdb->fetchInto($res)) {
         if ($summarize & 1) {
             reporton($row, $last_area_room, $last_date, $sortby, $display);
         }
         if ($summarize & 2) {
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:report.php


示例20: array

// Set $db_create to 0 to NOT create the database.
$db_create = 1;
// Communication protocol tu use. For pgsql, you can use 'unix' instead of
// 'tcp' to use Unix Domain Sockets instead of TCP/IP.
$db_protocol = "tcp";
/**************************
* DBMS specific options
***************************/
//****ORACLE*****
// Home directory path where Oracle is installed if it is running in the local machine.
// Default value: value of the environment variable ORACLE_HOME
$oci8_home = "";
/**************************
* End of database settings
***************************/
include_once "MDB.php";
MDB::loadFile("Manager");
$schema_file = "mrbs.schema.xml";
$variables = array("database_name" => $db_database, "database_create" => $db_create);
$dsn = array("phptype" => $dbsys, "username" => $db_login, "password" => $db_password, "hostspec" => $db_host, "protocol" => $db_protocol, "port" => $db_port);
$options = array("HOME" => $oci8_home, "optimize" => 'portability');
$manager = new MDB_manager();
$manager->connect($dsn, $options);
$success = $manager->updateDatabase($schema_file, $schema_file . ".before", $variables);
if (MDB::isError($success)) {
    echo "Error: " . $success->getMessage() . "<BR>";
    echo "Error: " . $success->getUserInfo() . "<BR>";
}
if (count($manager->warnings) > 0) {
    echo "WARNING:<BR>", implode($manager->getWarnings(), "!\n"), "\n";
}
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:mrbs_create.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MDB2类代码示例发布时间:2022-05-23
下一篇:
PHP MD5Crypt类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap