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


PHP medoo::query方法代码示例

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


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

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $conf = array();
     include "config.inc.php";
     self::$conf = $conf;
     $ds = self::$conf['db'];
     $database = new medoo(array('database_type' => 'mysql', 'database_name' => $ds['db'], 'server' => $ds['host'], 'port' => $ds['port'], 'username' => $ds['user'], 'password' => $ds['password']));
     $ut_data_schema = $ds['ut_data_schema'];
     $database->query(self::$conf["create_fixture_db"]);
     $database->query(self::$conf["populate_fixture_db"]);
     $database->query("drop database if exists {$ut_data_schema}; create database {$ut_data_schema};");
 }
开发者ID:Adapp,项目名称:propagator,代码行数:12,代码来源:PropagatorModelTest.php

示例2: catch

} catch (Exception $e) {
    die("Failed to connect to the database\r\n");
}
foreach ($cachefiles as $cachefile) {
    if (!file_exists($cachefile)) {
        touch($cachefile);
    }
}
if (empty($action)) {
    $response['error'] = true;
    $response['message'] = "Missing parameters";
    echo json_encode($response);
}
switch ($action) {
    case "CurrentPlayers":
        $return = $database->query("SELECT SUM(players) AS player_total, SUM(slots) AS slot_total FROM server_details")->fetchAll()[0];
        $response['data'] = array('players' => $return['player_total'], 'slots' => $return['slot_total']);
        echo json_encode($response);
        break;
    case "TotalServers":
        $total = $database->query("SELECT COUNT(*) AS server_total FROM server_details;")->fetchAll()[0];
        $empty = $database->query("SELECT COUNT(*) AS server_notempty FROM server_details WHERE players!=0;")->fetchAll()[0];
        $response['data'] = array('servers' => $total['server_total'], 'serversplayers' => $empty['server_notempty']);
        echo json_encode($response);
        break;
    case "History":
        $return = $database->query("SELECT * FROM archive WHERE timestamp > DATE_SUB(CURDATE(), INTERVAL 2 DAY);")->fetchAll();
        $chartData = [];
        foreach ($return as $data) {
            $record["players"] = $data["currentplayers"];
            $record["slots"] = $data["currentslots"];
开发者ID:Celant,项目名称:Yuuki,代码行数:31,代码来源:stats.php

示例3: medoo

try {
    $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $dbhost, 'username' => $dbuser, 'password' => $dbpass, 'port' => $dbport, 'charset' => 'utf8']);
} catch (Exception $e) {
    die("Failed to connect to the database\r\n");
}
foreach ($cachefiles as $cachefile) {
    if (!file_exists($cachefile)) {
        touch($cachefile);
    }
}
if (empty($action)) {
    $response['error'] = true;
    $response['message'] = "Missing parameters";
    echo json_encode($response);
}
switch ($action) {
    case "CurrentPlayers":
        $return = $database->query("SELECT SUM(players) AS player_total, SUM(slots) AS slot_total FROM server_details;")->fetchAll()[0];
        $response['data'] = array('players' => $return['player_total'], 'slots' => $return['slot_total']);
        echo json_encode($response);
        break;
    case "TotalServers":
        $return = $database->query("SELECT COUNT(*) AS server_total FROM server_details;")->fetchAll()[0];
        $response['data'] = array('servers' => $return['server_total']);
        echo json_encode($response);
        break;
    default:
        $response['error'] = true;
        $response['message'] = "Unrecognized endpoint";
        break;
}
开发者ID:WhiteXZ,项目名称:Yuuki,代码行数:31,代码来源:stats.php

示例4: dbHasError

<?php

defined("TEMPLATES_PATH") or define("TEMPLATES_PATH", realpath(dirname(__FILE__) . '/view'));
defined("LIBRARY_PATH") or define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/lib'));
include LIBRARY_PATH . '/medoo.min.php';
if (isset($_GET['install']) and !file_exists(LIBRARY_PATH . '/database.db') and isset($_POST['username']) and isset($_POST['pwd']) and isset($_POST['rpt']) and $_POST['pwd'] == $_POST['rpt']) {
    $db = new medoo(LIBRARY_PATH . '/database.db');
    $db->query("CREATE TABLE users (username TEXT,password TEXT);");
    $db->query("CREATE TABLE settings (setting TEXT,value TEXT);");
    $db->query("CREATE TABLE hosts (domain TEXT,checkInTime TEXT,description TEXT);");
    $db->insert("users", ["username" => strtolower($_POST['username']), "password" => password_hash($_POST['pwd'], PASSWORD_DEFAULT)]);
    $db->insert("settings", ["setting" => "secretKey", "value" => rand()]);
    if (!$db->error()[0] == "00000") {
        unlink(LIBRARY_PATH . '/database.db');
        $noticeMessage = "An error occurred while saving the database.";
    } else {
        $noticeMessage = "Successfully installed DropPoint control. Please login.";
    }
}
if (!file_exists(LIBRARY_PATH . '/database.db')) {
    include TEMPLATES_PATH . '/setup.php';
    exit;
}
$db = new medoo(LIBRARY_PATH . '/database.db');
$secretCode = $db->get("settings", "value", ["setting" => "secretKey"]);
function dbHasError()
{
    global $db;
    if ($db->error()[0] == "00000") {
        return false;
    } else {
开发者ID:bhassani,项目名称:dropPoint,代码行数:31,代码来源:droppoint.php

示例5: array

 */
echo "_______________\n";
$last_user_id = $database->insert("test", array("user" => "fooa", "email" => "foo@bar.com", "id" => 25, "pwd" => "smart", "name" => array("en", "fr", "jp", "cn")));
echo $database->last_query();
/*
 * quote函数,单引号
 */
echo "_______________\n";
$data = "Medoo";
echo "we love" . $data . "\n";
echo "we love" . $database->quote($data);
/*
 * query()函数
 */
echo "_______________\n";
$data1 = $database->query("select * from test")->fetchAll();
print_r($data1);
/*
 * where的使用
 */
echo "_______________\n";
$re = $database->select('test', 'user', array("id" => 25));
echo $re[0];
/*
 * where的使用(in)
 */
$re = $database->select('test', 'user', array("id" => array(25, 30, 100)));
echo $re[0];
/*
 * where的使用(between)
 */
开发者ID:keensting,项目名称:MeetingManageSystem,代码行数:31,代码来源:testmedoo.php

示例6: query

 public function query($query)
 {
     array_push($this->logs, $query);
     Log::sql($this->last_query());
     array_push($this->queries, $this->last_query());
     return parent::query($query);
 }
开发者ID:kokororin,项目名称:Kotori.php,代码行数:7,代码来源:Database.php

示例7: medoo

 * Time: 23:38
 */
require_once 'vendor/autoload.php';
//open database connection
$database = new medoo(['database_type' => 'mysql', 'database_name' => 'r8db', 'server' => '172.16.2.109', 'username' => 'admin', 'password' => 'admin', 'charset' => 'utf8']);
$user_id = $database->select("user", ["[>]entry" => "user_id"], ["entry.entry_id"], ["entry_id" => 10]);
$user = $database->get('user', ['[>]entry' => "user_id"], ['user_id', 'email', 'username', 'admin', 'nsfw'], ['entry_id' => 10]);
$html = '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"><div class="container"><div class="row">';
$html .= '<form class="clearfix" method="get">
<div class="form-group col-sm-4"><label for="action">Action</label><select class="form-control" name="action" id="action"><option value="show">show</option><option value="delete">delete</option><option value="add">add</option><option value="set">set</option></select></div>
<div class="form-group col-sm-4"><label for="amount">Amount</label><input class="form-control" type="number" name="amount" id="amount" value=""></div>
<div class="form-group col-sm-4"><label>Functions</label><div><button type="submit" class="btn btn-primary">Submit</button> <button type="reset" class="btn btn-warning">Reset</button></div></div>
</form>';
$html .= '</div><div class="row"><div class="col-sm-12">';
$count = $database->count('entry');
$database->query('ALTER TABLE "entry" AUTO_INCREMENT = ' . ($count + 1));
if (isset($_GET['action'])) {
    $amount = isset($_GET['amount']) && is_numeric($_GET['amount']) ? intval($_GET['amount']) : 100;
    if ($_GET['action'] == 'delete' && $count != 0) {
        $database->delete('entry', ['ORDER' => 'entry_id DESC', 'LIMIT' => $amount]);
    } elseif ($_GET['action'] == 'delete') {
        $html .= 'Where nothing is, nothing can be removed.';
    } elseif ($_GET['action'] == 'add') {
        for ($i = $count + 1; $i < $count + $amount + 1; ++$i) {
            $data = ['user_id' => 1, 'category_id' => 1, 'title' => 'Dummy #' . $i, 'desc' => 'Lorem Ipsum', 'image' => 'https://placehold.it/400x400'];
            $database->insert('entry', $data);
        }
    } elseif ($_GET['action'] == 'set') {
        $database->delete('entry', ['LIMIT' => 99999999999999]);
        $count = $database->count('entry');
        $database->query('ALTER TABLE "entry" AUTO_INCREMENT = 1');
开发者ID:thedodobird2,项目名称:M307,代码行数:31,代码来源:entryDB.php

示例8: medoo

define('ADDSFOLDER', '/mnt/Beijing/AddRemoverFiles/Reklamer/');
require_once 'lib/medoo.php';
$db = json_decode(file_get_contents('python/database.json'), TRUE);
$database = new medoo(['database_type' => 'mysql', 'database_name' => $db['db'], 'server' => 'localhost', 'username' => $db['user'], 'password' => $db['passwd'], 'charset' => 'utf8']);
if ($_POST) {
    switch ($_POST['submit']) {
        case 'Update':
            $database->insert("states", ["date" => time(), "active" => $_POST['active']]);
            break;
        case 'Import':
            $database->insert("configurations", ["name" => $_POST['name'], "date" => time(), "folder" => $_POST['folder'], "samplerate" => $_POST['samplerate'], "window_size" => $_POST['window_size'], "overlap_ratio" => $_POST['overlap_ratio'], "fan_value" => $_POST['fan_value'], "neighborhood_size" => $_POST['neighborhood_size'], "min_hash" => $_POST['min_hash'], "max_hash" => $_POST['max_hash'], "fingerprint_redux" => $_POST['fingerprint_redux']]);
            $output = shell_exec(IMPORTSCRIPT);
            break;
    }
}
$columns = $database->query("DESCRIBE configurations")->fetchAll();
$active = $database->query("SELECT active FROM states ORDER BY id DESC")->fetch();
$configs = $database->select("configurations", "*");
$channels = glob(ADDSFOLDER . '*');
foreach ($channels as $channel) {
    $dates = glob($channel . '/*', GLOB_ONLYDIR);
    $channel = end(explode("/", $channel));
    foreach ($dates as $period) {
        $c[$channel][] = $period;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
开发者ID:pimpmypixel,项目名称:dejavu_server,代码行数:31,代码来源:form.php

示例9: fopen

<?php

/**导入学校信息
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/20
 * Time: 14:27
 */
require_once '../../medoo/medoo.php';
$file = fopen('../assert/school.txt', 'r') or die('文件打开失败!');
$db = new medoo();
while ($v = fgets($file)) {
    $v = str_replace('"', '', $v);
    $re = $db->query($v);
    print_r($v);
}
开发者ID:keensting,项目名称:ErhuoAmbass,代码行数:16,代码来源:school_import.php

示例10: function

use Psr\Http\Message\ResponseInterface;
$app = new \Slim\App();
$app->get('/', function (ServerRequestInterface $request, ResponseInterface $response, $args) use($app, $config) {
    $db_directory = $config['database_dir'];
    $db_path = $config['database_filepath'];
    $db_exists = file_exists($db_path);
    if ($db_exists) {
        $body = '<p>The database already exists.</p>';
    } else {
        if (!is_dir($db_directory) || !is_writable($db_directory)) {
            $body = '<p>' . $db_directory . ' and ' . $db_path . ' must exist and <strong>both</strong> be writable.' . '</p>';
        } else {
            $db = new medoo(['database_type' => 'sqlite', 'database_file' => '../db/mediaserver.db']);
            $query = 'CREATE TABLE "media" (
        mediaId INTEGER PRIMARY KEY,
        filepath VARCHAR(1024) UNIQUE,
        title VARCHAR(512),
        description TEXT
      )';
            $data = $db->query($query);
            if (file_exists($db_path)) {
                $body = '<p>Installed. It was probably successful, but who knows? Cool, huh?</p>';
            } else {
                $body = '<p>Installation appears to have failed; no database was created.</p>';
            }
        }
    }
    $response->write($body);
    return $response;
});
$app->run();
开发者ID:travis-bradbury,项目名称:mediaserver,代码行数:31,代码来源:install.php

示例11: server

<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/secrets.php';
$tables = ['server' => "CREATE TABLE server(\n\t\t`id` VARCHAR(36) NOT NULL,\n\t\t`address` CHAR(45),\n\t\t`port` INT NOT NULL,\n\t\t`providertoken` VARCHAR(36),\n\t\t`notlegacy` TINYINT(1) DEFAULT 0,\n\t\t`lastupdate` BIGINT NOT NULL,\n\t\tPRIMARY KEY (id)\n\t\t) ENGINE=InnoDB;", 'server_settings' => "CREATE TABLE `server_settings` (\n\t\t`id` MEDIUMINT NOT NULL AUTO_INCREMENT,\n\t\t`serverid` VARCHAR(50) NOT NULL,\n\t\tPRIMARY KEY (`id`),\n\t\tCONSTRAINT `FK_SERVER_ID_SETTINGS` FOREIGN KEY (`serverid`) REFERENCES `server` (`id`)\n\t\t\tON DELETE CASCADE\n\t\t\tON UPDATE CASCADE\n\t\t) ENGINE=InnoDB;", 'server_details' => "CREATE TABLE `server_details`(\n\t\t`id` MEDIUMINT NOT NULL AUTO_INCREMENT,\n\t\t`serverid` VARCHAR(50) NOT NULL,\n\t\t`players` INT,\n\t\t`slots` INT,\n\t\t`memory` BIGINT,\n\t\tPRIMARY KEY (`id`),\n\t\tCONSTRAINT `FK_SERVER_ID_DETAILS` FOREIGN KEY (`serverid`) REFERENCES `server` (`id`)\n\t\t\tON DELETE CASCADE\n\t\t\tON UPDATE CASCADE\n\t\t) ENGINE=InnoDB;"];
$events = ['timeout' => "CREATE EVENT timeout_server\n\t\t\tON SCHEDULE EVERY 1 MINUTE\n\t\t\tDO DELETE FROM server WHERE lastupdate < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 6 MINUTE));"];
echo "Connecting to Database\r\n";
try {
    $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $dbhost, 'username' => $dbuser, 'password' => $dbpass, 'port' => $dbport, 'charset' => 'utf8']);
} catch (Exception $e) {
    die("Failed to connect to the database\r\n");
}
echo "Connection succesful\r\n";
echo "Checking if required tables exist\r\n";
foreach ($tables as $key => $value) {
    $result = $database->query("SHOW TABLES LIKE '" . $key . "'")->fetchAll();
    if (empty($result)) {
        echo "Creating missing table '" . $key . "'\r\n";
        $database->query($value);
    }
}
foreach ($events as $key => $value) {
    $result = $database->query("SHOW EVENTS LIKE '" . $key . "'")->fetchAll();
    if (empty($result)) {
        echo "Creating missing event '" . $key . "'\r\n";
        $database->query($value);
    }
}
echo "All tables present and accounted for!\r\n";
echo "Installation complete!\r\n";
开发者ID:WhiteXZ,项目名称:Yuuki,代码行数:30,代码来源:install.php

示例12: query

 /**
  * @param $query
  * @return \PDOStatement
  */
 public function query($query)
 {
     return $this->_writer->query($query);
 }
开发者ID:dalinhuang,项目名称:StudentManage,代码行数:8,代码来源:sql.php

示例13: medoo

<?php

require "db/medoo.php";
$db = new medoo(array('database_type' => 'mysql', 'database_name' => 'cm', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8'));
if ($_POST) {
    $db->insert('stat', array('name' => $_POST['name'], 'email' => $_POST['email'], 'point' => $_POST['point']));
    $maxPoint = intval($_POST['point']);
    $isExist = $db->select('max_point', array('max_point', 'id'), array('email' => $_POST['email']));
    if ($isExist) {
        if ($_POST['point'] > $isExist[0]['max_point']) {
            $db->update('max_point', array('max_point' => $_POST['point']), array('id' => $isExist[0]['id']));
        } else {
            $maxPoint = $isExist[0]['max_point'];
        }
    } else {
        $db->insert('max_point', array('email' => $_POST['email'], 'max_point' => $_POST['point']));
    }
    $rank = $db->query('select count(*) as rank from stat where point > ' . $maxPoint)->fetch();
    $rank = $rank['rank'] + 1;
    echo json_encode(array('max_point' => $maxPoint, 'rank' => $rank));
}
开发者ID:jamokop,项目名称:cm,代码行数:21,代码来源:index.php

示例14: medoo

$db = new medoo();
session_start();
$_SESSION['page1']=1;
$codefieldName = md5(uniqid('auth', true));
$_SESSION['codefieldName'] = $codefieldName;
$quizName = '';

/* Quiz take page! for the chirruns */
$quizid = $_REQUEST["quizid"];
if (isset($_REQUEST['quizid']) && ! preg_match('/^\d+$/', $quizid)) {
	$error  = 'Invalid Quiz';
}

/* Double check this quiz is even active, ready and within dates */
if ($quizid > 0) {
	$checkQuiz = $db->query("SELECT quizid, quizName FROM quiz WHERE status='ready' AND active=1 AND availableDate <= NOW() AND endAvailableDate >= NOW() AND quizid=".$quizid );
	foreach($checkQuiz as $quiz) {
		$quizid=$quiz['quizid'];
		$quizName = $quiz['quizName'];
	}
	if ($quizName == '') {
		header('Location:/index.php');
		exit();
	} 
}
include('header.php');
?>
<h1>Quiz: <?php 
echo $quizName;
?>
</h1>
开发者ID:kangamoo,项目名称:Qikpop,代码行数:31,代码来源:index.php

示例15: medoo

<?php

require 'goygoy.php';
require 'm.php';
echo "++ G0yg0y is starting ++ <br>";
$database = new medoo(['database_type' => 'mysql', 'database_name' => "old", 'server' => '127.0.0.1', 'username' => $u, 'password' => $p, 'charset' => 'utf8', 'port' => 3306, 'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]]);
$database->query("\n\nDROP TABLE IF EXISTS old.cargo, old.users, old.comments;\n\nCREATE TABLE IF NOT EXISTS `cargo` (\n`id` int(32) NOT NULL,\n  `no` bigint(32) DEFAULT NULL,\n  `status` varchar(255) DEFAULT NULL\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;\n\n\n\nINSERT INTO `cargo` (`id`, `no`, `status`) VALUES\n(1, 100, 'Ali\\'s cargo on the way'),\n(2, 101, 'Mehmet\\'s cargo on the way');\n\n\nCREATE TABLE IF NOT EXISTS `users` (\n`id` int(11) NOT NULL,\n  `username` varchar(32) DEFAULT NULL,\n  `password` varchar(32) DEFAULT NULL\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;\n\n\nINSERT INTO `users` (`id`, `username`, `password`) VALUES\n(1, 'admin', '21232f297a57a5a743894a0e4a801fc3'),\n(1, 'guest', '084e0343a0486ff05530df6c705c8bb4');\n\n\nCREATE TABLE IF NOT EXISTS `comments` (\n`id` int(11) NOT NULL,\n  `subject` varchar(255) DEFAULT NULL,\n  `comment` longblob\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;\n\n\nALTER TABLE `cargo`\n ADD PRIMARY KEY (`id`);\n\nALTER TABLE `users`\n ADD PRIMARY KEY (`id`);\n\nALTER TABLE `comments`\n ADD PRIMARY KEY (`id`);\n\n\nALTER TABLE `cargo`\nMODIFY `id` int(32) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;\n\nALTER TABLE `users`\nMODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;\n\nALTER TABLE `comments`\nMODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;\n\n\n");
sleep(3);
header("Location: login.php");
exit;
//var_dump( $database->log() );
开发者ID:xsuperbug,项目名称:g0yg0y,代码行数:11,代码来源:setup.php


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