/** * @return array */ public function info() { $rt = array('write' => $this->_writer->info(), 'read' => NULL); if (empty($this->_reader)) { $rt['read'] = $rt['write']; } else { $rt['read'] = $this->_reader->info(); } return $rt; }
/** * 导入数据到 wd_120answer_temp 中 * @author gaoqing * 2015年11月9日 * @param array $initAskArr 初始要导入的问答信息集 * @param int $preInsertCount 每次插入的条数 * @param medoo $connection 连接数据库对象 * @param int $sleepSeconds 休眠的秒数 * @return int $importCount 成功导入的信息数 */ function importData($initAskArr, $preInsertCount, $connection, $sleepSeconds) { $importCount = 0; $data = array("isimport" => 1); $insertArr = array(); $updateIDArr = array(); $initAskArrCount = count($initAskArr); foreach ($initAskArr as $key => $initAsk) { if ($key % 100 == 0) { sleep($sleepSeconds); } $insertArr[] = getInserArr($initAsk); $updateIDArr[] = $initAsk['id']; if ($key % $preInsertCount == $preInsertCount - 1 || $key == $initAskArrCount - 1) { //将 $insertArr 数组集,插入到 wd_fhanswer_temp 中 if (!empty($insertArr)) { //插入到 wd_120answer_temp 中 $idArr = $connection->insert(IMPORT_TABLE, $insertArr); $importCount += count($insertArr); $insertArr = array(); //更新 wd_120answer_keshi 中的信息 $where = array('id' => $updateIDArr); $connection->update(SELECT_TABLE, $data, $where); $updateIDArr = array(); } } } return $importCount; }
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); }
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); }
function login() { if (session_id() == '') { session_start(); } if (isset($_POST["mail"]) & isset($_POST["password"]) & isset($_POST["cre"])) { if ($_POST["mail"] != "" and $_POST["password"] != "" and $_POST["cre"] != "") { $mail = $_POST["mail"]; $password = $_POST["password"]; $role = $_POST["cre"]; require_once 'SessionManager.php'; $session_manager = new SessionManager(); require_once 'medoo.min.php'; $database = new medoo(); $count = $database->count("triotrack_users", ["email" => "{$mail}"]); if ($count > 0) { $profile = $database->get("triotrack_users", ["username", "password", "salt", "client"], ["email" => "{$mail}"]); if ($role === "admin") { if ($profile["password"] === sha1($password . $profile["salt"])) { $username = $profile["username"]; $client = $profile["client"]; $cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}"); $encoded_cookie = $session_manager->encode_session(json_encode($cookie)); $_SESSION["user_id"] = $encoded_cookie; setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/"); // 86400 = 1 day echo "admin"; exit; } else { echo "failed"; exit; } } else { if ($profile["client"] === $password) { $username = $profile["username"]; $client = $profile["client"]; $cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}"); $encoded_cookie = $session_manager->encode_session(json_encode($cookie)); $_SESSION["user_id"] = $encoded_cookie; setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/"); // 86400 = 1 day echo "client"; exit; } else { echo "failed"; exit; } } } } else { echo "failed"; } exit; } }
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};"); }
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; }
/** * 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; }
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 ); */ }
/** * MedooDB constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('database'); } if (!isset($conf['charset'])) { $conf['charset'] = 'utf8'; } parent::__construct($conf); }
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); }
/** * 构造器,对生成异常进行捕获 * @param array $setting 数据库配置信息 */ function __construct($setting) { if (!is_array($setting)) { return; } try { parent::__construct($setting); $this->status = true; } catch (\Exception $ex) { $this->ex_message = $ex->getMessage(); } }
/** * 构造函数 * @param $component_appid * @param $component_appsecret * @param $component_verify_ticket */ public function __construct($options) { $db_config = (require_once '/alidata/www/weixin/framework/config/db.php'); $wxcachedb_config = $db_config[strtoupper('wxcachedb_config')]; require_once '/alidata/www/weixin/framework/orm/medoo.php'; $this->db = medoo::getInstance($wxcachedb_config); $this->cache_table_name = 'component'; $this->component_appid = isset($options['component_appid']) ? $options['component_appid'] : ''; $this->component_appsecret = isset($options['component_appsecret']) ? $options['component_appsecret'] : ''; $this->memc = $this->getMemcached(); $this->prefix = $this->component_appid . '_component_'; $this->component_access_token = $this->getComponentAccessToken(); }
public function getAjaxMethods() { $whereClause = $this->getRPCWhere($this->currentClass); $dbData = $this->dbQuery(array('AND' => $whereClause)); if (is_array($dbData) === false) { $errorMsg = "Cannot get data from db."; if (EMA_DEBUG === true) { $errorArray = $this->dbConnection->error(); $errorMsg .= " Debug Data: " . $errorArray[2]; } throw new FatalError($errorMsg, 6022); } if (count($dbData) === 0) { return false; } $methodsArray = array(); foreach ($dbData as $method) { $methodsArray[] = $method['methodName']; } return $methodsArray; }
<?php $app->get('/admin', function () use($app) { global $dbCredentials; $database = new medoo($dbCredentials); $invoices = $database->select("invoice", ["id", "modified", "currency", "company", "name", "address", "type"], ["ORDER" => "modified DESC"]); foreach ($invoices as $id => $invoice) { $invoices[$id]['lines'] = $database->select("line", ["id", "description", "charge", "quantity", "is_hours"], ["invoice_id" => $invoice['id'], "ORDER" => "id ASC"]); } $app->render('admin/admin.html.twig', ['invoices' => $invoices]); })->setName('home');
/** * 删除图片 * @param bool $rt * @param int $id * @param int $uid * @param \medoo $write_db * @return bool */ public function deletePictureFeed($rt, $id, $uid, \medoo $write_db) { if ($rt !== true || $id < 1 || $uid < 1) { return $rt; } $write_db->delete("feed", ['sid' => "SharePicture_" . $id]); if ($write_db === false) { Log::write("deletePictureFeed Error", Log::SQL); return false; } return true; }
<?php /** * Created by PhpStorm. * User: zy * Date: 2015/11/3 * Time: 14:06 */ require_once '../../lib/medoo.php'; // Initialize $database = new medoo(['database_type' => 'mysql', 'database_name' => 'easycurd', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']); $username = $_POST['username']; $password = $_POST['password']; echo $password; echo $username; $database->select('ec_user', ['name' => 'foo', 'email' => '*****@*****.**', 'age' => 25, 'lang' => ['en', 'fr', 'jp', 'cn']]); if ($result = $database) { //µÇ¼³É¹¦ session_start(); $_SESSION['username'] = $username; exit; } else { exit('µÇ¼ʧ°Ü£¡µã»÷´Ë´¦ <a href="javascript:history.back(-1);">·µ»Ø</a> ÖØÊÔ'); }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); session_start(); require_once 'meedoo.php'; require_once 'config.php'; $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; $appHome = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/apps/meals/'; $database = new medoo(); $email = $_GET["email"]; $password1 = $_GET["password"]; $password = md5($password1 . $salt); $profile = $database->get("users", ["name", "password"], ["email" => $email]); $profile_pw = $profile['password']; $profile_name = $profile['name']; if ($password == $profile_pw) { $_SESSION['user'] = $email; $_SESSION['name'] = $profile_name; echo 'good'; } else { echo 'bad'; }
/** * Created by PhpStorm. * User: KeenSting * Date: 2015/7/1 * Time: 16:22 */ //todo,改变meting表中会议状态validity // todo,inform 中增加一项 //todo,1,attendence中检索meeting id,2,对应状态state设置为0 无效,3,对应user id写成新的notice,4,并将user表中的mes改为当前inform_id $mid = $_POST['id']; session_start(); $id = $_SESSION['uid']; include '../../parameter/Medoo/Resource/medoo.php'; //meeting $db = new medoo('meetingmanage'); $db->update('meeting', array('VALIDITY' => 1), array('MEETING_ID' => $mid)); // ////inform $re = $db->select('inform', 'CONTENT', array('MEETING_ID' => 40002)); $content = $re[0]; $new_mes = "注意:关于【" . $content . "】的会议已经取消,请您确认信息!"; $iid = $db->max('inform', 'INFORM_ID'); $iid += 1; $date = date("Y/m/d"); $db->insert("inform", array('INFORM_ID' => $iid, 'USER_ID' => $id, 'DATE' => $date, 'CONTENT' => $new_mes, 'MEETING_ID' => $mid)); //attendence //获得user列表 $users = $db->select('attendence', 'USER_ID', array('MEETING_ID' => 40000)); //跟新参会状态 $db->update('attendence', array('STATE' => 0), array('MEETING_ID' => $mid));
<?php require_once 'medoo.php'; $database = new medoo(array('database_type' => 'pgsql', 'database_name' => 'wid', 'server' => 'localhost', 'username' => 'wid_owner', 'password' => 'widowner', 'charset' => 'utf8', 'port' => 5432, 'prefix' => 'wid_schema.')); $data = $database->select("tblu_storage_view_vt", array('state', 'storage_name', 'city', 'drainage', 'data_provider_name', 'reporting_date', 'today_volume_active', 'today_capacity_active', 'today_proportion_full'), array('ORDER' => array('state ASC', 'storage_name ASC'))); echo '<pre>'; print_r($data); /* $database = new medoo( array( 'database_type' => 'pgsql', 'database_name' => 'dellstore2', 'server' => 'localhost', 'username' => 'postgres', 'password' => 'Jiqiang@1977', 'charset' => 'utf8', 'port' => 5432 ) ); echo '<pre>'; print_r($database->info()); $data1 = $database->select( // Table name. 'cust_hist', // Joins. array( '[><]customers' => 'customerid', '[><]products' => 'prod_id',
<?php ini_set('display_errors', 'ON'); error_reporting(E_ALL); header("Content-type:text/html;charset=utf-8"); defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__)); include ROOT_PATH . '/../lib/medoo.php'; include ROOT_PATH . '/../lib/Curl.php'; $db = new medoo(array('database_type' => 'mysql', 'database_name' => 'fayuan', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'port' => 3306, 'charset' => 'utf8', 'option' => array(PDO::ATTR_CASE => PDO::CASE_NATURAL))); $curl = new Curl(); $id = 2250; while ($id <= 1239000) { $url = "http://shixin.court.gov.cn/detail?id={$id}"; $resArr = getHtml($url); echo "{$id}\r\n"; if (is_array($resArr) && !empty($resArr)) { //判断数据是否存在 print_r($resArr); $i = $db->insert('shixin', $resArr); if ($i <= 0) { print_r($db->error()); die; } } $id++; } function getHtml($url) { global $curl; $curl->setUrl($url); $html = $curl->run();
<?php /** * 获取留言对方姓名 * * */ header("Content-type:text/html; charset=utf8"); $id = $_POST['id']; include_once './medoo/medoo.php'; $database = new medoo(); $sql = $database->select("user", array("name"), array("id" => $id)); if ($sql) { $result['state'] = "success"; $result['message'] = "成功得到对方姓名"; $result['info'] = $sql; $result_json = json_encode($result); echo $result_json; } else { $result['state'] = "error"; $result['message'] = "获取对方姓名失败"; $result_json = json_encode($result); echo $result_json; }
<?php /** * Created by PhpStorm. * User: wangxiaofeng * Date: 11/23/15 * Time: 9:02 PM */ session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); date_default_timezone_set("asia/shanghai"); include "../../medoo.php"; include '../../function.php'; $database = new medoo(['database_type' => 'mysql', 'database_name' => 'gongre', 'server' => 'localhost', 'username' => 'root', 'password' => 'xidryhm00', 'charset' => 'utf8', 'port' => 3306, 'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]]); $action = ""; $act = ""; if ($_SERVER['REQUEST_METHOD'] === 'GET') { $action = htmlspecialchars($_GET["action"]); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $act = htmlspecialchars($_POST["act"]); } if ("login" === $action) { $opid = $_GET["username"]; $pw = $_GET["password"]; $data = $database->select("gr_op", "*", ["opid" => $opid]); if (count($data) > 0) { if ($data[0]["pw"] == $pw) { $_SESSION["opid"] = $opid;
<?php //include 'Insertdb2.php'; include "himpdf/mpdf.php"; require 'medoo.php'; require 'config.php'; print_r($_GET); $txnid = $_GET["txnid"]; $txnid = stripcslashes($txnid); $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $servername, 'username' => $username, 'password' => $dbpassword]); $datas = $database->select("applicant", "*", ["txnid" => $txnid]); //print_r($datas); $message = file_get_contents('confirmaitonmail.php'); $message = str_replace("applicant_uname", $datas[0]['username'], $message); $message = str_replace("applicant_name", $datas[0]['applicant_name'], $message); $message = str_replace("applicant_email", $datas[0]['email'], $message); $message = str_replace("applicant_gname", $datas[0]['gname'], $message); $message = str_replace("applicant_presentadd", $datas[0]['presentadd'], $message); $message = str_replace("applicant_permanentadd", $datas[0]['permanentadd'], $message); $message = str_replace("applicant_phone", $datas[0]['mobile'], $message); $message = str_replace("applicant_dob", $datas[0]['dob'], $message); $message = str_replace("applicant_gender", $datas[0]['gender'], $message); $message = str_replace("applicant_cast", $datas[0]['cast'], $message); $message = str_replace("applicant_nationality", $datas[0]['nationality'], $message); $message = str_replace("applicant_postapplying", $datas[0]['postapplying'], $message); if ($datas[0]['cast'] == gen) { $amount = "200"; } else { $amount = "100"; } $message = str_replace("applicant_amount", $amount, $message);
<?php session_start(); error_reporting(null); date_default_timezone_set('Asia/Shanghai'); include "./medoo.min.php"; $database = new medoo(); if (isset($_POST['uid']) && isset($_POST['qid'])) { $database->insert("who", array("qid" => $_POST['qid'], "uid" => $_POST['uid'])); $database->update("question", array("isreply" => 1), array("id" => $_POST['qid'])); header("Location: manager.php"); }
<?php require '../vendor/autoload.php'; require '../secrets.php'; $data = json_decode(urldecode($_GET['data']), true); $data['address'] = $_SERVER['REMOTE_ADDR']; $output = array(); $hash = md5($data['address'] . ":" . $data['port']); $disableDB = false; if (!$disableDB) { 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"); } $record = $database->get("server", "id", ["id" => $hash]); if (empty($record)) { $database->insert("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()]); $database->insert("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']]); } else { $database->update("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()], ["id" => $hash]); $database->update("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']], ["serverid" => $hash]); } } $output["success"] = "Ok"; echo json_encode($output);
$result['h_count'] = $h_count; if ($status == 'lockedin') { $result['lockedin'] = true; if ($role == 'f') { foreach ($users as $user) { if ($user['role'] == 'f' || $user['role'] == 'h') { array_push($result["users"], $user); } } } } return $result; } require 'lib/medoo.php'; try { $database = new medoo(['database_type' => 'mysql', 'database_name' => 'secret_h', 'server' => 'localhost', 'username' => 'recipe', 'password' => 'mPu92jfqRJSVMa8H', 'charset' => 'utf8']); $method = ""; $user_id = $_SESSION['user_id']; if ($_GET != null) { $method = $_GET['method']; } else { if ($_POST != null) { $method = $_POST['method']; } } //print( $method ); if (strcmp($method, "checkUserName") == 0) { $data = $database->select("users", "user_name", ["user_name" => $_GET['user_name']]); print json_encode($data); } else { if ($method == "login") {
<?php /* * 显示任务详情 * * */ header("Content-type:text/html; charset=utf8"); $id = $_POST['id']; include_once './medoo/medoo.php'; $database = new medoo(); $sql = $database->select("task", array("id", "time", "writer", "details", "timelong"), array("id" => $id)); if ($sql) { $result = array(); $result['state'] = "success"; $result['message'] = "get task success!"; $result['info'] = $sql; $result_json = json_encode($result); echo $result_json; } else { $result = array(); $result['state'] = "error"; $result['message'] = "get task error!select not work!"; $result_json = json_encode($result); echo $result_json; }
<?php require_once 'medoo.php'; require_once '../../php/inc.php'; $database = new medoo(['database_type' => 'mysql', 'database_name' => $DB, 'server' => $SERVIDOR, 'username' => $USUARIO, 'password' => $CLAVE, 'charset' => 'utf8']); $item = $_GET['item']; $tabla = $TABLA['usuarios']; $where = ['OR' => ['Nombre[~]' => $item, 'Cedula[~]' => $item]]; //$columnas['usuarios'] = ['id', 'Nombre', 'Cedula', 'Empresa', 'FechaReg', 'activo']; $columnas['usuarios'] = ['id', 'Nombre', 'Cedula', 'FechaReg', 'activo']; $data = $database->select($TABLA['usuarios'], $columnas['usuarios'], $where); foreach ($data as $llave => $valor) { $data[$llave]['Usuario'] = $data[$llave]['Cedula'] . ' ' . $data[$llave]['Nombre']; } echo json_encode($data, JSON_UNESCAPED_UNICODE);
function controleer_email($email) { $database = new medoo(); $emailExists = $database->count("gebruikers", ["AND" => ["email" => $email]]); /* If exectly one user has been found */ if ($emailExists == 1) { return false; } else { return true; } }