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


PHP MDB类代码示例

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


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


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