select() public method

查找记录
public select ( array $options = [] ) : array
$options array 表达式
return array
Example #1
1
 public function getUsers($restId)
 {
     $db = new Db();
     $table = "rest" . $restId . "_users";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $local_query = "SELECT * FROM `{$table}`";
     $result = $db->select($local_query);
     $userCount = count($result);
     $configurationTable = "rest" . $restId . "_userConfigurations";
     $configurationMappingTable = "rest" . $restId . "_userConfigurationMapping";
     $userTable = "rest" . $restId . "_users";
     $local_query = "SELECT M.`userID`,M.`configurationID`, C.`configurationName`,C.`configurationDisplayText`, C.`configurationType`, \n\t\tC.`configurationTag`, C.`configurationValueBinary`, C.`configurationValueText`, C.`configurationValueDecimal`, C.`comments`,M.`isAllowed` FROM \n\t\t`{$configurationMappingTable}` AS M INNER JOIN `{$configurationTable}` AS C ON `M`.`configurationID` = `C`.`configurationID`  \n\t\tORDER BY   M.`userID`, M.`configurationID`";
     $resultConfiguration = $db->select($local_query);
     $configurationCount = count($resultConfiguration);
     for ($i = 0; $i < $userCount; $i++) {
         $result[$i]['Permissions'] = array();
         for ($j = 0; $j < $configurationCount; $j++) {
             if ($result[$i]['ID'] == $resultConfiguration[$j]['userID']) {
                 array_push($result[$i]['Permissions'], $resultConfiguration[$j]);
             }
         }
     }
     for ($i = 0; $i < $userCount; $i++) {
         for ($j = 0; $j <= count($result[$i]['Permissions']); $j++) {
             unset($result[$i]['Permissions'][$j]['userID']);
         }
     }
     $response = array();
     $response["Users"] = $result;
     return $response;
 }
Example #2
0
 /**
  * Example of an Endpoint
  */
 protected function games($_args)
 {
     // var_dump($this->method);
     // var_dump($this->endpoint);
     // var_dump($this->verb);
     // var_dump($this->args);
     // var_dump($this->file);
     // var_dump($this->request);
     $db = new Db();
     if ($this->method == 'GET') {
         // /games/id
         if (count($this->args)) {
             return $this->_response($db->select($this->endpoint, $this->args[0]));
             // /games/search?name=value
         } elseif ($this->verb === "search") {
             return $this->_response($db->search($this->endpoint, $this->request));
             // /games/
         } else {
             return $this->_response($db->select($this->endpoint));
         }
         // /games/?name=value1&description=value2
     } elseif ($this->method == 'POST') {
         return $this->_response($db->insert($this->endpoint, $this->request));
     } elseif ($this->method == 'PUT') {
         return $this->_response("UPDATE method not found", 404);
     } elseif ($this->method == 'DELETE') {
         return $this->_response("DELETE method not found", 404);
     } else {
         return $this->_response("Request error ", 500);
     }
 }
Example #3
0
 public function getDiscountInfo($restId)
 {
     $table = "rest" . $restId . "_discountMaster";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $discountVoucherTable = "rest" . $restId . "_discountVoucher";
     $discountSlotsTable = "rest" . $restId . "_discountSlots";
     $db = new Db();
     $local_query = "SELECT * FROM `{$table}`";
     $result = $db->select($local_query);
     foreach ($result as $key => $value) {
         if ($value["isVoucherEnabled"]) {
             $temp = $value["discountID"];
             $voucher_query = "SELECT `ID`, `voucherCode`, `validFromUTC`,\n  \t\t\t `validFromLocal`, `validToUTC`, `validToLocal`, `timeZone`, `isUsed`,\n  \t\t\t  `orderIDUsedOn`, `customerID` FROM `{$discountVoucherTable}` WHERE discountID = '{$temp}'";
             $voucher = $db->select($voucher_query);
             $result[$key]["Voucher Details"] = $voucher;
         }
     }
     foreach ($result as $key => $value) {
         if ($value["isSlotted"]) {
             $temp = $value["discountID"];
             $slot_query = "SELECT * FROM `{$discountSlotsTable}` WHERE discountID = '{$temp}'";
             $slot = $db->select($voucher_query);
             $result[$key]["Slot Details"] = $slot;
         }
     }
     return $result;
 }
Example #4
0
 function init($module, $lang, $language, $idURL, $categorie, $sscategorie, $type, $sort, $order, $page, $settings, $search)
 {
     $getColumn = Db::select(TABLE_PREFIX . CATEGORIE_NOM, "0");
     $output = "";
     $output = TemplateAdd::debutadd($module, $lang, $language, $categorie, $sscategorie, $sort, $order, $page, $search);
     for ($i = 0; $i < Db::num_fields($getColumn); $i++) {
         // Boucle sur les colonnes
         $column = Db::fetch_field($getColumn);
         $column = $column->name;
         $add = "";
         $column = Utils::findColumn($column, $language);
         $field = Utils::findField($column);
         // Trouve le type de donne et affiche le input adequat
         if ($field == "id" && $settings['blanc']['showId'] == true || $field != "id") {
             if (@(!(include_once 'fields/' . $field . '.field.php'))) {
                 // Regarde si le champ est predefini. Si pas, on utilise le champ txt par defaut
                 $field = "txt";
             } else {
                 if (class_exists($field)) {
                     $add = stripslashes(htmlentities($add, ENT_QUOTES, "iso-8859-1"));
                     $getValue = new $field($lang, $add, $column, "", $categorie, $sscategorie, "add", $sort, $page, $settings);
                     $add = $getValue->add;
                     if ($this->exclusion($sscategorie, $column)) {
                         $output .= TemplateAdd::add($add);
                     }
                 }
             }
         }
     }
     $output .= TemplateAdd::finadd($module, $lang);
     return $output;
 }
 /**
  * 收藏列表
  *
  * @param array $condition 检索条件
  * @param obj $obj_page 分页对象
  * @return array 数组类型的返回结果
  */
 public function getFavoritesList($condition, $page = '')
 {
     $condition_str = $this->_condition($condition);
     $param = array('table' => 'flea_favorites', 'where' => $condition_str, 'order' => $condition['order'] ? $condition['order'] : 'fav_time desc');
     $result = Db::select($param, $page);
     return $result;
 }
Example #6
0
 public static function getList($query = '', $vars = array())
 {
     if (empty($query)) {
         $query = 'SELECT * FROM ' . self::getDbTable();
     }
     return self::_getList(Db::select($query, $vars));
 }
Example #7
0
 public function backupInit($config)
 {
     F('_backup_', '[del]');
     //创建目录
     if (!is_dir($config['dir']) && !mkdir($config['dir'], 0755, true)) {
         View::error('目录创建失败', $config['url']);
     }
     $table = Db::getAllTableInfo();
     $table = $table['table'];
     foreach ($table as $d) {
         //limit起始数
         $table[$d['tablename']]['first'] = 0;
         //文件编号
         $table[$d['tablename']]['fileId'] = 1;
     }
     $cache['table'] = $table;
     $cache['config'] = $config;
     //备份表结构
     $tables = Db::getAllTableInfo();
     $sql = "<?php if(!defined('HDPHP_PATH'))EXIT;\n";
     foreach ($tables['table'] as $table => $data) {
         $createSql = Db::select("SHOW CREATE TABLE {$table}");
         $sql .= "Db::execute(\"DROP TABLE IF EXISTS {$table}\");\n";
         $sql .= "Db::execute(\"{$createSql[0]['Create Table']}\");\n";
     }
     if (file_put_contents($config['dir'] . '/structure.php', $sql)) {
         file_put_contents($config['dir'] . '/config.php', "<?php return " . var_export($config, true) . ";");
         F('_backup_', $cache);
         return true;
     } else {
         F('_backup_' . '[del]');
         $this->error = '表结构备份失败';
         return false;
     }
 }
Example #8
0
 public function getshou($condition, $page = '')
 {
     $condition_str = $this->_condition($condition);
     $param = array('table' => 'taolun', 'where' => $condition_str, 'order' => $condition['order'] ? $condition['order'] : 'add_time desc');
     $result = Db::select($param, $page);
     return $result;
 }
Example #9
0
 public function Retrive($cin)
 {
     $bdd = new Db();
     $query = "SELECT * FROM card WHERE cin=" . $cin;
     $result = $bdd->select($query);
     return $result;
 }
Example #10
0
 function init($module, $lang, $language, $idURL, $categorie, $sscategorie, $type, $sort, $order, $page, $settings, $search)
 {
     $getEntry = Db::select(TABLE_PREFIX . CATEGORIE_NOM, $idURL);
     $entry = Db::fetch_row($getEntry);
     $getColumn = Db::select(TABLE_PREFIX . CATEGORIE_NOM, "0");
     $output = "";
     $output = TemplateUpdate::debutupdate($module, $lang, $language, $categorie, $sscategorie, $sort, $order, $page, $idURL, $search);
     for ($i = 0; $i < Db::num_fields($getColumn); $i++) {
         // Boucle sur les colonnes
         $column = Db::fetch_field($getColumn);
         $column = $column->name;
         $update = $entry[$i];
         $column = Utils::findColumn($column, $language);
         $field = Utils::findField($column);
         // Trouve le type de donné et affiche le input adéquat
         if ($field == "id" && $settings['blanc']['showId'] == true || $field != "id") {
             if (@(!(include_once 'fields/' . $field . '.field.php'))) {
                 // Regarde si le champ est prédéfini. Si pas, on utilise le champ txt par défaut
                 $field = "txt";
             } else {
                 if (class_exists($field)) {
                     if ($field == "date") {
                         $update = Utils::datefr($update);
                     }
                     $update = stripslashes(htmlentities($update, ENT_QUOTES, "iso-8859-1"));
                     $getValue = new $field($lang, $update, $column, $idURL, $categorie, $sscategorie, $type, $sort, $page, $settings);
                     $update = $getValue->update;
                     $output .= TemplateUpdate::update($update);
                 }
             }
         }
     }
     $output .= TemplateUpdate::finupdate($module, $lang);
     return $output;
 }
Example #11
0
 /**
  * @return array
  */
 public function fetch()
 {
     $query = $this->db->select('*', $this->table, $this->where, $this->order, $this->limit);
     $results = $this->db->fetchAssoc($query);
     $return = array();
     if ($results) {
         foreach ($results as $result) {
             $item = new $this->class();
             foreach ($result as $name => $value) {
                 $item->{":{$name}"} = $value;
             }
             $return[] = $item;
         }
     }
     return $return;
 }
Example #12
0
 /**
  * 好友列表
  *
  * @param	array $condition	条件数组
  * @param	string $field 	显示字段
  * @param	obj $obj_page 	分页
  * @param	string $type 	查询类型
  */
 public function listFriend($condition, $field = '*', $obj_page = '', $type = 'simple')
 {
     //得到条件语句
     $condition_str = $this->getCondition($condition);
     $param = array();
     switch ($type) {
         case 'simple':
             $param['table'] = 'sns_friend';
             break;
         case 'detail':
             $param['table'] = 'sns_friend,member';
             $param['join_type'] = 'INNER JOIN';
             $param['join_on'] = array('sns_friend.friend_tomid=member.member_id');
             break;
         case 'fromdetail':
             $param['table'] = 'sns_friend,member';
             $param['join_type'] = 'INNER JOIN';
             $param['join_on'] = array('sns_friend.friend_frommid=member.member_id');
             break;
     }
     $param['where'] = $condition_str;
     $param['field'] = $field;
     $param['order'] = $condition['order'] ? $condition['order'] : 'sns_friend.friend_id desc';
     $param['limit'] = $condition['limit'];
     $param['group'] = $condition['group'];
     $friend_list = Db::select($param, $obj_page);
     return $friend_list;
 }
Example #13
0
 public function getComplainGoods($condition = '', $page = '')
 {
     $param = array();
     $param['table'] = 'complain_goods';
     $param['where'] = $this->getCondition($condition);
     $param['order'] = $condition['order'] ? $condition['order'] : ' complain_goods_id desc ';
     return Db::select($param, $page);
 }
Example #14
0
 public static function rawClientes($where = null)
 {
     if ($where) {
         $sql = Db::select("\n            select c.id, c.nome, ci.nome as cidade, uf.uf, ra.ramo_atividade, if(f.cliente_id IS NOT NULL, true, null) as is_fisica, if(j.cliente_id IS NOT NULL, true, null) as is_juridica, j.nome_fantasia, j.inscricao_municipal from cliente c\n            left join cliente_pf f on f.cliente_id = c.id\n            left join cliente_pj j on j.cliente_id = c.id\n            left join ramo_atividade ra on ra.id = c.ramo_atividade_id\n            left join cidade ci on ci.id = c.cidade_id\n            left join uf on uf.id = c.uf_id\n\n            where ativo = '1' and (nome like '%" . $where . "%' or nome_fantasia like '%" . $where . "%' or cidade like '%" . $where . "%' or uf like '%" . $where . "%' or ramo_atividade like '%" . $where . "%')\n\n            group by c.id order by c.nome\n\n        ");
         return $sql;
     }
     return Db::select("\n            select c.id, c.nome, ci.nome as cidade, uf.uf, ra.ramo_atividade, if(f.cliente_id IS NOT NULL, true, null) as is_fisica, if(j.cliente_id IS NOT NULL, true, null) as is_juridica, j.nome_fantasia, j.inscricao_municipal from cliente c\n            left join cliente_pf f on f.cliente_id = c.id\n            left join cliente_pj j on j.cliente_id = c.id\n            left join ramo_atividade ra on ra.id = c.ramo_atividade_id\n            left join cidade ci on ci.id = c.cidade_id\n            left join uf on uf.id = c.uf_id\n\n            where ativo = '1'\n            group by c.id order by c.nome\n\n        ");
 }
Example #15
0
	/**
	 * 列表
	 *
	 * @param array $condition 检索条件
	 * @param obj $page 分页
	 * @return array 数组结构的返回结果
	 */
	public function getLinkList($condition,$page=''){
		$param = array();
		$param['table'] = 'mb_category';
//		$param['where'] = $condition_str;
		$param['order'] = $condition['order'] ? $condition['order'] : 'gc_id';
		$result = Db::select($param,$page);
		return $result;
	}
Example #16
0
 public function getAllAttr($goods_id, $type_id)
 {
     $sql = "SELECT * FROM hd_goods_attr ga \n\t\t\t\tRIGHT JOIN hd_shop_attr sa \n\t\t\t\tON ga.attr_id=sa.attr_id \n\t\t\t\tWHERE sa.shop_type_id = {$type_id}\n\t\t\t\tAND (ga.goods_id={$goods_id} OR ga.goods_id is null) \n\t\t\t\tORDER BY sa.attr_type DESC, sa.attr_id ASC";
     $data = Db::select($sql);
     // $data = Db::table('goods_attr ga')->rightJoin('shop_attr sa','ga.attr_id','=','sa.attr_id')->where('sa.shop_type_id',$shop_type_id)->get();
     return $data;
     // return $this->where('goods_id',$goods_id)->get();
 }
Example #17
0
 public static function pos($inmueble)
 {
     $pos = Db::fetchOne(Db::select(array('pos' => 'MAX(posicion)'), 'inmuebles_paginas', array('inmueble_id' => $inmueble)));
     if (empty($pos)) {
         $pos = 0;
     }
     return $pos;
 }
 public function getInformSubjectType($condition = '', $page = '')
 {
     $param = array();
     $param['table'] = 'inform_subject_type';
     $param['where'] = $this->getCondition($condition);
     $param['order'] = $condition['order'] ? $condition['order'] : ' inform_type_id desc ';
     return Db::select($param, $page);
 }
Example #19
0
 public function getMenu($restId)
 {
     $db = new Db();
     $table = "rest" . $restId . "_menu";
     $local_query = "SELECT * FROM `{$table}` WHERE isActive=1 AND menuID ";
     $data = $db->select($local_query);
     return $data;
 }
Example #20
0
 /**
  * 列表
  *
  * @param array $condition 检索条件
  * @param obj $page 分页
  * @return array 数组结构的返回结果
  */
 public function getList($condition, $page = '')
 {
     $param = array();
     $param['table'] = 'mb_feedback';
     $param['order'] = 'ftime desc';
     $result = Db::select($param, $page);
     return $result;
 }
 /**
  * 模板列表
  *
  * @param array $condition 检索条件
  * @return array 数组形式的返回结果
  */
 public function getTemplatesList($condition)
 {
     $condition_str = $this->_condition($condition);
     $param = array();
     $param['table'] = 'mail_msg_temlates';
     $param['where'] = $condition_str;
     $result = Db::select($param);
     return $result;
 }
Example #22
0
	/**
	 * 列表
	 *
	 * @param array $condition 检索条件
	 * @param obj $page 分页
	 * @return array 数组结构的返回结果
	 */
	public function getLinkList($condition,$page=''){
		$condition_str = $this->_condition($condition);
		$param = array();
		$param['table'] = 'link';
		$param['where'] = $condition_str;
		$param['order'] = $condition['order'] ? $condition['order'] : 'link_id';
		$result = Db::select($param,$page);
		return $result;
	}
 public function getActiveComplainSubject($condition = '', $page = '')
 {
     //搜索条件
     $condition['complain_subject_state'] = 1;
     $param['table'] = 'complain_subject';
     $param['where'] = $this->getCondition($condition);
     $param['order'] = $condition['order'] ? $condition['order'] : ' complain_subject_id desc ';
     return Db::select($param, $page);
 }
Example #24
0
function tbladdressbook()
{
    $db = new Db();
    $rows = $db->select("SELECT ID, addressbook_FullName,addressbook_AddressLine1,addressbook_AddressLine2 FROM dbtest.addressbook");
    echo "<table border=1 style=  width:100%><th> Full Name</th><th>Address Line1</th><th>Address Line 2</th></tr>";
    foreach ($rows as $col => $val) {
        echo '<td><a href="addressbook_edit.php?id=' . $val['ID'] . '">' . $val['addressbook_FullName'] . ' </a></td><td>' . $val["addressbook_AddressLine1"] . "</td><td>" . $val["addressbook_AddressLine2"] . "</td></tr>";
    }
}
 /**
  * 列表
  *
  * @param array $condition 检索条件
  * @return array 数组结构的返回结果
  */
 public function getUploadList($condition)
 {
     $condition_str = $this->_condition($condition);
     $param = array();
     $param['table'] = 'album_pic';
     $param['where'] = $condition_str;
     $result = Db::select($param);
     return $result;
 }
Example #26
0
	/**
	 * 类别列表
	 *
	 * @param array $condition 检索条件
	 * @return array 数组结构的返回结果
	 */
	public function getClassList($condition){
		$condition_str = $this->_condition($condition);
		$param = array();
		$param['table'] = 'article_class';
		$param['where'] = $condition_str;
		$param['order']	= empty($condition['order'])?'ac_parent_id asc,ac_sort asc,ac_id asc':$condition['order'];
		$result = Db::select($param);
		return $result;
	}
 public function getComplainTalk($condition = '', $page = '', $field = '*')
 {
     $param = array();
     $param['table'] = 'complain_talk';
     $param['field'] = $field;
     $param['where'] = $this->getCondition($condition);
     $param['order'] = $condition['order'] ? $condition['order'] : ' talk_id desc ';
     return Db::select($param, $page);
 }
Example #28
0
	/**
	 * 列表
	 *
	 * @param array $condition 检索条件
	 * @param obj $page 分页
	 * @return array 数组结构的返回结果
	 */
	public function getNavigationList($condition,$page){
		$condition_str = $this->_condition($condition);
		$param = array();
		$param['table'] = 'navigation';
		$param['where'] = $condition_str;
		$param['order']	= $condition['order'] ? $condition['order'] : 'nav_id';
		$result = Db::select($param,$page);
		return $result;
	}
Example #29
0
 /**
  * 图片列表
  *
  * @param array $condition 查询条件
  * @param obj $page 分页对象
  * @return array 二维数组
  */
 public function getPicList($condition, $page = '', $field = '*')
 {
     $param = array();
     $param['table'] = 'album_pic';
     $param['where'] = $this->getCondition($condition);
     $param['order'] = $condition['order'] ? $condition['order'] : 'apic_id desc';
     $param['field'] = $field;
     return Db::select($param, $page);
 }
Example #30
0
	/**
	 * 根据条件
	 *
	 * @param array $condition 查询条件
	 * @param obj $page 分页对象
	 * @return array 二维数组
	 */
	public function getJoinList($condition,$page=''){
		$param	= array();
		$param['table']	= 'activity,activity_detail';
		$param['join_type']	= empty($condition['join_type'])?'right join':$condition['join_type'];
		$param['join_on']	= array('activity.activity_id=activity_detail.activity_id');
		$param['where']	= $this->getCondition($condition);
		$param['order']	= $condition['order'];
		return Db::select($param,$page);
	}