本文整理汇总了PHP中medoo类的典型用法代码示例。如果您正苦于以下问题:PHP medoo类的具体用法?PHP medoo怎么用?PHP medoo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了medoo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importData
/**
* 导入数据到 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: login
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;
}
}
示例5: 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};");
}
示例6: through_area_get_school
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;
}
示例7: 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;
}
示例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_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);
}
示例10: __construct
/**
* 构造函数
* @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();
}
示例11: function
<?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');
示例12: deletePictureFeed
/**
* 删除图片
* @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;
}
示例13: medoo
<?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' => 'foo@bar.com', '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> ÖØÊÔ');
}
示例14: ini_set
<?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';
}
示例15: session_start
/**
* 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));