本文整理汇总了PHP中medoo::select方法的典型用法代码示例。如果您正苦于以下问题:PHP medoo::select方法的具体用法?PHP medoo::select怎么用?PHP medoo::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类medoo
的用法示例。
在下文中一共展示了medoo::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
session_start();
// error_reporting(null);
if (!isset($_SESSION['uid'])) {
header("Location: login.php");
exit;
}
date_default_timezone_set('Asia/Shanghai');
include "./medoo.min.php";
$database = new medoo();
if (isset($_GET['qid']) && isset($_POST['reply'])) {
$name = $database->select("user", "name", array("id" => $_SESSION['uid']));
$database->insert("answer", array("qid" => $_GET['qid'], "name" => $name[0], "content" => $_POST['reply']));
$database->update("question", array("isanswer" => 1), array("id" => $_GET['qid']));
header("Location: my.php");
}
示例2: select
/**
* @param string $table
* @param array $join
* @param string|array $columns
* @param array $where
* @return array|bool
*
* Or,
* @param string $table
* @param string|array $columns
* @param array $where
* @return array|bool
*/
public function select($table, $join, $columns = null, $where = null)
{
$re = parent::select($table, $join, $columns, $where);
$this->lastSql = $this->last_query();
$this->lastError = $this->error();
return $re;
}
示例3: get_activity_list
protected function get_activity_list()
{
$local_db = new medoo();
$list = $local_db->select('activity', '*', array('state' => 1));
$list = two_dimension_array_sort::execute($list, 'id');
$this->assign('act_list', $list);
}
示例4: getInitAsk
/**
* 得到 wd_120answer_keshi 中的指定条数的问答
* @author gaoqing
* 2015年11月9日
* @param medoo $connection 连接数据库对象
* @param int $num 获取的条数
* @return array 指定条数的问答集
*/
function getInitAsk($connection, $num)
{
$initAskArr = array();
$where = array("isimport" => 0, "LIMIT" => [0, $num], "ORDER" => "age");
$initAskArr = $connection->select(SELECT_TABLE, "*", $where);
return $initAskArr;
}
示例5: get_salary_list
protected function get_salary_list()
{
$total = 0;
$local = new medoo();
$user_list = array();
//需要发工资的大使的ekey列表
$salary_list = array();
//所有未结算列表
$list = $local->select('salary', array('[>]ambassador' => 'ekey'), array('ekey', 'num', 'ambassador.zfb_id', 'ambassador.name'), array('is_give' => 0));
// print_r($list);
//检索出用户列表,拍重,统计总额
foreach ($list as $v) {
$total += $v['num'];
$user_list[$v['ekey']] = '';
}
//填充工资列表的工资总额
foreach ($user_list as $k => $v) {
$num = 0;
$name = '';
$zfb_id = '';
foreach ($list as $l) {
if ($l['ekey'] == $k) {
$num += $l['num'];
$name = $l['name'];
$zfb_id = $l['zfb_id'];
}
}
$salary_list[] = array('name' => $name, 'ekey' => $k, 'num' => $num, 'zfb_id' => $zfb_id);
}
$this->assign('info', array('total' => $total, 'person' => count($user_list)));
$this->assign('salary_list', $salary_list);
}
示例6: dbQuery
protected final function dbQuery($where)
{
$result = $this->dbConnection->select(AUTOLOADER_TABLE, array('[>]' . self::GP_CLASS_METHODS_TABLE => array('id' => 'classId')), '*', $where);
if ($result === false) {
throw new FatalError('Error getting GP policy: ' . print_r($this->dbConnection->error(), true));
}
return $result;
}
示例7: select
/**
* @param $table
* @param $join
* @param null $columns
* @param null $where
* @return array|bool
*/
public function select($table, $join, $columns = NULL, $where = NULL)
{
if (empty($this->_reader)) {
return $this->_writer->select($table, $join, $columns, $where);
} else {
return $this->_reader->select($table, $join, $columns, $where);
}
}
示例8: getResults
function getResults($text, $index1, $index2)
{
include_once "medoo.min.php";
// Initialize medoo
$database = new medoo(['database_type' => 'mysql', 'database_name' => 'anecdote_gimme', 'server' => '108.167.140.108', 'username' => 'anecdote_je', 'password' => 'hackChamps']);
// get the categories
$cats = $database->select("words", "category_id", ["name" => $text]);
// select the results from the ids
$results = array();
$results[] = $database->select("places", ["name", "address", "telephone", "website", "image", "category_id", "longitude", "latitude"], ["AND" => ["category_id" => $cats], "ORDER" => "description DESC", "LIMIT" => [$index1, $index2]]);
/*
* echo "<pre>";
* print_r($results);
* echo "</pre>";
*/
return $results;
/*
* $database->select ( "places", [
* "words" => ["words.category_id" => "places.category_id"],
* "categories" => ["categories.id" => "words.category_id"]
* ], [
* "places.name",
* "places.address",
* "places.telephone",
* "categories.name"
* ], [
* "words" => $text
* ] );
*/
/*
* include_once 'mySQL_connection.php';
*
* $req = $bdd->prepare ( "SELECT p.name, p.address, p.telephone, c.name
* FROM places p
* INNER JOIN words w ON w.category_id = p.category_id
* INNER JOIN categories c ON c.id = w.category_id
* WHERE w.name = :word" );
* $req->execute(array("word" => $text));
* $data = $req->fetch();
* $req->closeCursor();
* return json_encode ( $data );
*/
}
示例9: get_all_data
/**
*获得统计表部分数据
*/
protected function get_all_data()
{
$medoo = new medoo();
$db = new maindb();
$counter = array();
if ($_SESSION['userinfo']['auth'] == 0) {
$register_all = $db->count('p_user', array('uid'), array('uid[>]' => 0));
$authority_all = $db->count('p_user', array('auth'), array('auth' => 1));
$register_invite = $db->count('p_user', array('invite'), array('invite[!]' => ''));
$authority_invite = $db->count('p_user', '*', array('AND' => array('invite[!]' => '', 'auth' => 1)));
$counter = array('register_all' => $register_all, 'authority_all' => $authority_all, 'register_invite' => $register_invite, 'authority_invite' => $authority_invite, 'register_nature' => $register_all - $register_invite, 'authority_nature' => $authority_all - $authority_invite);
} elseif ($_SESSION['userinfo']['auth'] == 1) {
$counter = school_handler::manager_area_data_load($_SESSION['userinfo']['province']);
} elseif ($_SESSION['userinfo']['auth'] == 2) {
$counter = array('register_all' => 0, 'authority_all' => 0, 'register_invite' => 0, 'authority_invite' => 0, 'register_nature' => 0, 'authority_nature' => 0);
}
$this->assign('counter', $counter);
//todo 根据身份推送不同的信息列表
//list数据获取
if ($_SESSION['userinfo']['auth'] == 0) {
//管理员推送所有数据
$num = $medoo->count('ambassador', '*', array('auth[>]' => 0));
$list = $medoo->select('ambassador', '*', array('auth[>]' => 0, 'LIMIT' => 20));
} elseif ($_SESSION['userinfo']['auth'] == 1) {
//省级主管,推送区域内数据
$num = $medoo->count('ambassador', '*', array('AND' => array('province' => $_SESSION['userinfo']['province'], 'auth' => 2)));
$list = $medoo->select('ambassador', '*', array('AND' => array('province' => $_SESSION['userinfo']['province'], 'auth' => 2), 'LIMIT' => 20));
} elseif ($_SESSION['userinfo']['auth'] == 2) {
$num = 1;
$list = array();
}
unset($medoo);
unset($db);
$this->data_package($list, $num);
//填充欠缺数据,推送到前端
// $db=new maindb();
// $re=$db->select('p_user','*',array(
// 'invite'=>$_SESSION['userinfo']['ekey'],
// 'LIMIT'=>1,
// ));
}
示例10: Redis
static function through_area_get_school($area)
{
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$list = $redis->lRange($area, 0, 500);
if (empty($list)) {
$local = new medoo();
$list = $local->select('school', 'name', array('area' => $area));
unset($local);
}
unset($redis);
return $list;
}
示例11: user_login
/**
* Verifies user login and logs in
* returns false if invalid login details
* else true
*/
public function user_login($username, $password)
{
$db = new medoo($this->config['db']);
$result = $db->select('users', ['userid', 'password', 'type'], ['username' => $username]);
if (count($result) == 0) {
return False;
}
if (password_verify($password, $result[0]['password'])) {
$_SESSION['userid'] = $result[0]['userid'];
$_SESSION['user_type'] = $result[0]['type'];
return True;
}
return False;
}
示例12: getListQuery
/**
* A wrapper for medoo select function
* @param string $fields
* @param array $where
* @return array
* @throws \Exception
*/
protected function getListQuery($fields = "*", $where = array())
{
if (EMA_DEBUG && EMA_LOG_SQL_QUERIES) {
$this->logSelectQuery($this->dbTable, $fields, $where);
}
$dbData = $this->dbConnection->select($this->dbTable, $fields, $where);
if (is_array($dbData) === false) {
$this->throwMysqlError();
}
$parsedData = array();
foreach ($dbData as $record) {
$record = $this->checkResult($record);
$parsedData[] = $this->parseJson($record);
}
return $parsedData;
}
示例13: get_order_list
protected function get_order_list()
{
$local = new medoo();
$remote = new maindb();
$list = $local->select('orders', '*', array('ekey' => $this->key));
if (!empty($list)) {
foreach ($list as &$v) {
$info = $remote->select('p_order', '*', array('id' => $v['order_id']));
//将unix时间戳转化为日期
$v['u_time'] = date('Y-m-d H:i:s', $v['u_time']);
$v['c_time'] = date('Y-m-d H:i:s', $v['c_time']);
if ($info[0]['did'] > 0) {
$v['order_state'] = $this->state['-1'];
} else {
$v['order_state'] = $this->state[$info[0]['state']];
}
}
}
$this->assign('list', $list);
}
示例14: array
$json = json_decode($request_body, true);
if ($json['data']) {
$json = $json['data'];
}
$resultObj = array();
if ($json['recipe_id'] != null) {
$recipe_id = $json['recipe_id'];
$where = ['recipe_id' => $recipe_id];
$result = $database->update("recipe", $json, $where);
} else {
$result = $database->insert("recipe", $json);
$resultObj["recipe_id"] = $result;
}
print_r(json_encode($resultObj));
} else {
$data = $database->select("recipe", "*", []);
foreach ($data as &$row) {
$ingredients = $database->select("recipe_ingredient", ["[>]ingredient" => "ingredient_id", "[>]measure" => "measure_id"], "*", ["recipe_id" => $row["recipe_id"]]);
$row["ingredients"] = $ingredients;
foreach ($ingredients as &$ing) {
if ($ing["amount"] == 1) {
$ing["measure"] = $ing["measure_abbr"];
} else {
$ing["measure"] = $ing["measure_plural_abbr"];
}
}
}
print_r(json_encode($data));
}
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
示例15: Optimus
</head>
<body>
<div class="container">
<h1>SimplePoll</h1><br>
<?php
require "medoo.php";
require "vendor/autoload.php";
use Jenssegers\Optimus\Optimus;
$optimus = new Optimus(1206616819, 2051302971, 838816212);
$database = new medoo();
$getid = basename($_GET['q']);
$pid = (int) base62decode($getid);
echo '<img src="https://ga-beacon.appspot.com/UA-68001702-1/simplepoll/getpoll-' . $getid . '?pixel">';
$poll = $database->select("polls", ["title", "type", "botcheck", "ipcheck", "created"], ["id" => $pid]);
$poll = $poll[0];
if (empty($poll['type'])) {
die("<pre>\n███████╗██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ██╗ ██╗\n██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗ ██║ ██║██╔═████╗██║ ██║\n█████╗ ██████╔╝██████╔╝██║ ██║██████╔╝ ███████║██║██╔██║███████║\n██╔══╝ ██╔══██╗██╔══██╗██║ ██║██╔══██╗ ╚════██║████╔╝██║╚════██║\n███████╗██║ ██║██║ ██║╚██████╔╝██║ ██║ ██║╚██████╔╝ ██║\n╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝\n\n██████╗ ██████╗ ██╗ ██╗ ███╗ ██╗ ██████╗ ████████╗ ███████╗ ██████╗ ██╗ ██╗███╗ ██╗██████╗\n██╔══██╗██╔═══██╗██║ ██║ ████╗ ██║██╔═══██╗╚══██╔══╝ ██╔════╝██╔═══██╗██║ ██║████╗ ██║██╔══██╗\n██████╔╝██║ ██║██║ ██║ ██╔██╗ ██║██║ ██║ ██║ █████╗ ██║ ██║██║ ██║██╔██╗ ██║██║ ██║\n██╔═══╝ ██║ ██║██║ ██║ ██║╚██╗██║██║ ██║ ██║ ██╔══╝ ██║ ██║██║ ██║██║╚██╗██║██║ ██║\n██║ ╚██████╔╝███████╗███████╗ ██║ ╚████║╚██████╔╝ ██║ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║██████╔╝\n╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝\n</pre>");
}
//grab poll data
$results = $database->select("results", ["qid", "amount"], ["pid" => $pid]);
$questions = $database->select("questions", ["qid", "text"], ["pid" => $pid]);
//format questions
foreach ($questions as &$quest) {
$questdb[$quest['qid']]['text'] = $quest['text'];
}
//grab totals and add them to the questdb
$totalvotes = 0;
foreach ($results as &$rid) {
$totalvotes += $rid['amount'];