public function __construct() { $query = "Select * from `ROOT_SETTINGS` where `activated`='1' limit 0,1;"; $mySqlHelper = new MySqlHelper($query); $this->conf = $mySqlHelper->getDataRow(0); $this->hostName = $_SERVER["SERVER_NAME"]; $this->hostIp = $_SERVER["SERVER_ADDR"]; $this->remoteIp = $_SERVER["REMOTE_ADDR"]; }
/** * Получение из базы списка блоков шаблона указанной страницы. */ private function getTemplateBlocks() { $query = "select\n TB.`id`,\n TB.`block` \n from (select\n Te.`alias` as template\n from `Pages` as Pg left join `Templates` as Te\n on Pg.`template` = Te.`alias`\n where Pg.`alias` = '{$this->page}') \n as Te left join `TemplateBlocks` as TB\n on Te.`template` = TB.`template`"; $mySqlHelper = new MySqlHelper($query); $blocksData = $mySqlHelper->getAllData(); $this->blocks = array(); $i = 0; foreach ($blocksData as $block) { $this->blocks[$i]['id'] = $block['id']; $this->blocks[$i++]['block'] = $block['block']; } }
private function getMenuItemsData() { $query = "select\n MeIt.`menuItem`, MeIt.`page`, MeIt.`postfix`,\n MeIt.`url`, MeIt.`sequence`, \n MeIt.`target`, MeItPa.`parent`\n from (\n select\n MeIt.`id` as menuItem, MeItPa.`page`, MeItPa.`postfix`,\n MeIt.`url`, MeIt.`sequence`, MeIt.`target`\n from (\n select \n MeIt.`id`, MeIt.`url`, UrTa.`target`, MeIt.`sequence`\n from `MenuItems` as MeIt left join `UrlTarget` as UrTa\n on MeIt.`target` = UrTa.`id`\n where MeIt.`menu` = '" . $this->menuName . "'\n ) as MeIt left join `MenuItemsPage` as MeItPa\n on MeIt.`id` = MeItPa.`menuItem`\n ) as MeIt left join `MenuItemParent` as MeItPa\n on MeIt.`menuItem` = MeItPa.`menuItem`\n order by MeIt.`sequence` asc"; $mySqlHelper = new MySqlHelper($query); $this->menuItemsData = $mySqlHelper->getAllData(); foreach ($this->menuItemsData as $menuItem) { //$this->menuItems['parent']['menuItem']['key']; $parent = 0; if ($this->checkValue($menuItem['parent'])) { $parent = $menuItem['parent']; } $this->menuItems[$parent][$menuItem['menuItem']]['menuItem'] = $menuItem['menuItem']; $this->menuItems[$parent][$menuItem['menuItem']]['page'] = $menuItem['page']; $this->menuItems[$parent][$menuItem['menuItem']]['postfix'] = $menuItem['postfix']; $this->menuItems[$parent][$menuItem['menuItem']]['url'] = $menuItem['url']; $this->menuItems[$parent][$menuItem['menuItem']]['target'] = $menuItem['target']; $title = $this->getMenuLang($menuItem['menuItem']); $this->menuItems[$parent][$menuItem['menuItem']]['title'] = $title['title']; } }
/** * Получение информации о странице */ private function getPagesDate() { $query = "\n Select\n PgCoEl.`alias`, \n PgCoEl.`showTitle`, \n PgCoEl.`cssClasses`, \n PgCoEl.`componentElement`, \n PgCoEl.`template`, \n PgCoEl.`isMainPage`, \n PgCoEl.`index`, \n PgCoEl.`follow`, \n PgCoEl.`archive`,\n PgCoEl.`componentElementName`,\n PgCoEl.`component`, \n PgCoEl.`mainPage`, \n PgCoEl.`printPage`, \n PgCoEl.`mobilePage`, \n PgCoEl.`head`, \n PgCoEl.`bodyStart`, \n PgCoEl.`bodyEnd`,\n Te.`main` as templateMain, \n Te.`mobile` as templateMobile, \n Te.`print` as templatePrint\n from (\n Select\n Pg.`alias`, \n Pg.`showTitle`, \n Pg.`cssClasses`, \n Pg.`componentElement`, \n Pg.`template`, \n Pg.`isMainPage`, \n Pg.`index`, \n Pg.`follow`, \n Pg.`archive`,\n CoEl.`alias` as componentElementName,\n CoEl.`component`, \n CoEl.`mainPage`, \n CoEl.`printPage`, \n CoEl.`mobilePage`, \n CoEl.`head`, \n CoEl.`bodyStart`, \n CoEl.`bodyEnd`\n from `Pages` as Pg left join `ComponentsElements` as CoEl\n on Pg.`componentElement` = CoEl.`id`\n where Pg.`alias` = '" . $this->page . "'\n ) as PgCoEl left join `Templates` as Te\n on PgCoEl.`template` = Te.`alias`;"; $mySqlHelper = new MySqlHelper($query); $pageData = $mySqlHelper->getDataRow(0); $this->pageData['alias'] = $pageData['alias']; $this->pageData['showTitle'] = $pageData['showTitle'] > 0; $this->pageData['cssClasses'] = $pageData['cssClasses'] != null ? $pageData['cssClasses'] : ""; $this->pageData['componentElement'] = $pageData['componentElement']; $this->pageData['template'] = $pageData['template']; $this->pageData['isMainPage'] = $pageData['isMainPage'] > 0; $this->pageData['index'] = $pageData['index'] > 0; $this->pageData['follow'] = $pageData['follow'] > 0; $this->pageData['archive'] = $pageData['archive'] > 0; $this->pageData['componentElementName'] = $pageData['componentElementName']; $this->pageData['component'] = $pageData['component']; $componentElementPath = $this->componentPath . $this->pageData['component'] . "/" . $this->pageData['componentElementName'] . "/"; $this->pageData['mainPage'] = $componentElementPath . "/" . $pageData['mainPage']; $this->pageData['printPage'] = $componentElementPath . "/" . $pageData['printPage']; $this->pageData['mobilePage'] = $componentElementPath . "/" . $pageData['mobilePage']; $this->pageData['head'] = $pageData['head'] != null ? $componentElementPath . $pageData['head'] : null; $this->pageData['bodyStart'] = $pageData['bodyStart'] != null ? $componentElementPath . $pageData['bodyStart'] : null; $this->pageData['bodyEnd'] = $pageData['bodyEnd'] != null ? $componentElementPath . $pageData['bodyEnd'] : null; $this->pageData['templatePath'] = "./templates/" . $this->pageData['template'] . "/"; $this->pageData['templateMain'] = $this->pageData['templatePath'] . $pageData['templateMain']; $this->pageData['templateMobile'] = $this->pageData['templatePath'] . $pageData['templateMobile']; $this->pageData['templatePrint'] = $this->pageData['templatePath'] . $pageData['templatePrint']; }
<?php /* ---------------------------------------------------------------- Some examples of use ---------------------------------------------------------------- */ require "lib/MySqlHelper.php"; require "lib/ConditionType.php"; require "models/Person.php"; $dbHelper = new MySqlHelper("127.0.0.1", "root", "", "TestDb"); $dbHelper->open(); // Load data from a stored procedure (passing 1 parameter) $people = $dbHelper->loadDataFromStoredProcedure(Person . __CLASS__, "getPersonById", array(2)); echo "getPersonById<br />"; echo json_encode($people[0]); echo "<br /><br />"; // Load data from a stored procedure (passing 2 parameters) $people = $dbHelper->loadDataFromStoredProcedure(Person . __CLASS__, "findPersonByIdOrName", array(2, "er")); echo "findPersonByIdOrName<br />"; echo json_encode($people); echo "<br /><br />"; // Load data from a stored procedure (without parameters) $people = $dbHelper->loadDataFromStoredProcedure(Person . __CLASS__, "getPeople"); echo "getPeople<br />"; echo json_encode($people); echo "<br /><br />"; // Load data from a table $people = $dbHelper->loadDataFromTableOrView(Person . __CLASS__, "Person"); echo "Person table data<br />"; echo json_encode($people); echo "<br /><br />"; // Load data from a view
echo json_encode(array("code" => "200", "mess" => '修改成功!')); return; } else { echo json_encode(array("code" => "110", "mess" => '修改失败!')); return; } } elseif ($m == 'LISTADDADDRESS') { //添加地址并使用 $name = $_REQUEST['name']; $tel = $_REQUEST['tel']; $province = $_REQUEST['province']; $city = $_REQUEST['city']; $country = $_REQUEST['country']; $detail_address = $_REQUEST['detail_address']; $time = date('Y-m-d H:i:s', time()); $Mysql = new MySqlHelper(); //检查是否已经存在默认地址; $sqlcheck = "SELECT id FROM sh_store_address where userid={$userID} AND delstate='N' AND state='ON'"; $datacheck = $Mysql->FetchData($sqlcheck); $flag = count($datacheck); //如果存在默认地址,则设置为普通地址,如果不存在默认地址,则设置成默认地址。 if ($flag > 0) { $state = 'OFF'; } else { $state = 'ON'; } $sqlinaddress = "INSERT INTO sh_store_address (userid,provinceid,cityid,countyid,detailaddress,createtime,tel,`name`,state) VALUES ({$userID},{$province},{$city},{$country},'{$detail_address}','{$time}','{$tel}','{$name}','{$state}')"; $row = $Mysql->ExecuteSql($sqlinaddress); $sqlsearchid = "SELECT id FROM sh_store_address WHERE userid={$userID} ORDER BY createtime DESC LIMIT 1"; $datasearchid = $Mysql->FetchData($sqlsearchid); if ($row > 0) {
private function getAllLengs() { $query = "Select * from `Lang` order by `default` desc;"; $mySqlHelper = new MySqlHelper($query); $this->langs = $mySqlHelper->getAllData(); }
/** * Получение списка параметров для плагина. * @param type $id - id плагина. * @param type $plugin - имя плагина. */ private function getPluginParam($id, $plugin) { $query = "Select * from `PluginDefaultParam` where `plugin`='" . $plugin . "'"; $mySqlHelper = new MySqlHelper($query); $this->pluginsParam[$plugin]['default'] = $mySqlHelper->getAllData(); $query = "Select * from `PluginParam` where `plugin`='" . $id . "'"; $mySqlHelper = new MySqlHelper($query); $this->pluginsParam[$plugin]['page'] = $mySqlHelper->getAllData(); }
new Log("", "订单号为" . $orderNum . "的订单确认收货失败,sql===" . $sqlGet); echo json_encode(array("code" => "110", "mess" => '确认收货失败!')); return; } } elseif ($m == 'BUYNOW') { $gdetailid = $_REQUEST['gdetailid']; $addressId = $_REQUEST['addressId']; $sdnum = $_REQUEST['sdnum']; $remarks = $_REQUEST['remarks']; $expressprice = EXPRESSPRICE; if ($remarks == '') { $remarks = '无备注'; } $orderNum = date('YmdHis') . rand(100, 999); $sqlInfo = "SELECT detailid,dprice,dnum,state FROM sh_store_goods_detail WHERE detailid={$gdetailid}"; $Mysql = new MySqlHelper(); $dataInfo = $Mysql->FetchData($sqlInfo); if ($dataInfo[0]['state'] != 'ON') { echo json_encode(array("code" => "110", "mess" => '该商品已经下架!')); return; } if ($dataInfo[0]['dnum'] < $sdnum) { echo json_encode(array("code" => "110", "mess" => '库存量不足!')); return; } $price = $dataInfo[0]['dprice']; $totalmoney = $price * $sdnum + $expressprice; $time = date("Y-m-d H:i:s", time()); $Mysql->Query("BEGIN"); $sqlInToOrder = "INSERT INTO sh_store_order (userid,ordertime,paystate,deliverstate,orderstate,money,discountmoney,countmoney,realpay,paytype,remarks,address,phone,`name`,expressPrice,ordernum) SELECT {$userID},'{$time}','N', 'NOT','PRE',{$totalmoney},0,{$totalmoney},0,4,'{$remarks}',concat(ar2.areaname,ar1.areaname,ar.areaname,a.detailaddress) AS address,a.tel,a.`name`,{$expressprice},'{$orderNum}' FROM sh_store_address a JOIN sh_store_area ar ON a.countyid=ar.areaid JOIN sh_store_area ar1 ON a.cityid=ar1.areaid JOIN sh_store_area ar2 ON a.provinceid=ar2.areaid WHERE id={$addressId} AND a.userid={$userID} AND delstate='N' limit 1"; //new Log("","ssss".$sqlInToOrder);
<?php include_once '../../Bin/MySqlHelper.class.php'; //连接数据库 include_once "../../Bin/Log.class.php"; $Mysql = new MySqlHelper(); //$user = array('demo1','demo2','demo3','demo3','demo4'); $sqllimit = $_REQUEST['sqllimit']; $page = $_REQUEST['page']; //$page=0; //获取请求的页数 $start = $page * 5; $sqllimit = $sqllimit . " " . $start . ",5 "; //new Log('',$username.'修改的sql语句==='.$sqllimit); $query = $Mysql->FetchData($sqllimit); echo json_encode($query); return; //转换为json数据输出 ?>
/** * Получение параметров модуля. * @param String $createdModules - ID созданного модуля. * @return array - массив параметров. */ private function getModulesParam($createdModules) { $query = "Select * from `ModulesParam` where `module`='" . $createdModules . "';"; $mySqlHelper = new MySqlHelper($query); return $mySqlHelper->getAllData(); }
private function getSlidesData() { $query = "select * from `Slides` where `slider`='" . $this->name . "' order by `sequence` asc;"; $mySqlHelper = new MySqlHelper($query); $this->data['slides'] = $mySqlHelper->getAllData(); }
<?php session_start(); include_once '../../Bin/MySqlHelper.class.php'; include_once '../../Bin/Log.class.php'; $userID = $_SESSION['coustomid']; $m = $_REQUEST['m']; //设置默认地址; if ($m == 'GETAREA') { $areaid = $_REQUEST['areaID']; $sql = "SELECT * FROM sh_store_area WHERE fid={$areaid}"; $Mysql = new MySqlHelper(); $dataArea = $Mysql->FetchData($sql); echo json_encode($dataArea); return; }
function test() { $Mysql = new MySqlHelper(); return $row2 = $Mysql->ExecuteSql("INSERT INTO test (datatime,znum,onenum) VALUES ('2015-12-29',2,6)"); }
<?php session_start(); include_once '../Index/head.php'; include_once '../Bin/MySqlHelper.class.php'; include_once '../Bin/Function.php'; $Mysql = new MySqlHelper(); $userid = $_SESSION['coustomid']; $id = $_REQUEST['id']; //$id=19; $sqlprovince = "SELECT * FROM sh_store_area WHERE fid=0"; $dataTableProvince = $Mysql->FetchData($sqlprovince); $sqladdress = "SELECT * FROM sh_store_address WHERE id={$id} and userid={$userid}"; $dataTableAddress = $Mysql->FetchData($sqladdress); $flag = count($dataTableAddress); $sqlcity = "SELECT * FROM sh_store_area WHERE fid=" . $dataTableAddress[0]['provinceid']; $dataTableCity = $Mysql->FetchData($sqlcity); $sqlcountry = "SELECT * FROM sh_store_area WHERE fid=" . $dataTableAddress[0]['cityid']; $dataTableCountry = $Mysql->FetchData($sqlcountry); //查询商品信息 ?> <link rel="stylesheet" href="ResponsiveSlides/responsiveslides.css"> <link rel="stylesheet" href="ResponsiveSlides/demo/demo.css"> <script src="../Myjquery/JQUERY-CONFIRM/js/pretty.js"></script> <!-- Add the minified version of files from the /dist/ folder. -->
<?php session_start(); include_once '../Index/head.php'; include_once '../Bin/MySqlHelper.class.php'; include_once '../Bin/Function.php'; //图片链接,运费等配置信息 include_once 'action/config.php'; $Mysql = new MySqlHelper(); $userid = $_SESSION['coustomid']; $sqlprovince = "SELECT * FROM sh_store_area WHERE fid=0"; $dataTableProvince = $Mysql->FetchData($sqlprovince); //查询商品信息 $gdetailid = $_REQUEST['gdetailid']; $sdnum = $_REQUEST['sdnum']; if ($gdetailid != '' && $sdnum != '') { $flag = true; } ?> <link rel="stylesheet" href="ResponsiveSlides/responsiveslides.css"> <link rel="stylesheet" href="ResponsiveSlides/demo/demo.css"> <script src="../Myjquery/JQUERY-CONFIRM/js/pretty.js"></script> <!-- Add the minified version of files from the /dist/ folder. --> <!-- jquery-confirm files --> <link rel="stylesheet" type="text/css" href="../Myjquery/JQUERY-CONFIRM/css/jquery-confirm.css" />
<?php global $_PARAM; $query = "select * from `Jquery` where version='" . $_PARAM['version'] . "' and min='" . $_PARAM['min'] . "'"; $mySqlHelper = new MySqlHelper($query); $data = $mySqlHelper->getDataRow(0); $insertString = "<script type='text/javascript' src='./plugins/jquery/lib/" . $data['fileName'] . "'></script>"; echo $insertString; //echo $data['fileName']; ?>
<?php session_start(); include_once '../Index/head.php'; include_once '../Bin/MySqlHelper.class.php'; include_once '../Bin/Function.php'; //图片链接,运费等配置信息 include_once 'action/config.php'; $mysql = new MySqlHelper(); $gdid = $_REQUEST['gdid']; $sqlgoods = "SELECT * FROM sh_store_goods WHERE gdid=" . $gdid . " and state='ON' "; $datagoods = $mysql->FetchData($sqlgoods); $sqlgoodsdetail = "SELECT * FROM sh_store_goods_detail WHERE gdid=" . $gdid . " and state='ON' "; $datagoodsdetail = $mysql->FetchData($sqlgoodsdetail); $arrpic = explode("|", $datagoods[0]['gdpic']); //print_r($datagoods); $userID = $_SESSION['coustomid']; if ($userID == '') { $userID = '0'; } ?> <link rel="stylesheet" href="../Carwash/ResponsiveSlides/responsiveslides.css"> <link rel="stylesheet" href="../Carwash/ResponsiveSlides/demo/demo.css"> <link rel="stylesheet" href="jiaoben897/css/zzsc.css"> <link href="spinner/css/jquery.spinner.css" rel="stylesheet" type="text/css"> <script src="../Myjquery/JQUERY-CONFIRM/js/pretty.js"></script>
private function checkPageAlias($alias) { $query = "Select `alias` from `Pages` where `alias`='{$alias}';"; $mySqlHelper = new MySqlHelper($query); $pagesInfo = $mySqlHelper->getAllData(); return count($pagesInfo) > 0 ? true : false; }
public function updateNums($orderid = 0) { $Mysql = new MySqlHelper(); $where = ''; //两个条件满足一个就可以更改,orderid优先 if ($orderid < 1) { return false; } if ($orderid > 0) { $where = " where o.orderid={$orderid} "; } $sqlInfo = "SELECT d.goodsid,d.num FROM sh_store_order o JOIN sh_store_order_detail d ON o.orderid=d.orderid " . $where; new Log("", "" . $sqlInfo); $dataInfo = $Mysql->FetchData($sqlInfo); $row = count($dataInfo); if ($row > 0) { foreach ($dataInfo as $Items) { $upsql = "UPDATE sh_store_goods_detail SET dnum =dnum-" . $Items['num'] . " ,salenum =salenum+" . $Items['num'] . " WHERE detailid=" . $Items['goodsid']; $upRow = $Mysql->ExecuteSql($upsql); if ($upRow < 1) { new Log("", "更改商品数量失败,sql===" . $upsql); return false; } } return true; } else { return false; } }
<?php include_once '../../Bin/MySqlHelper.class.php'; $id = $_REQUEST['id']; if ($id > 0) { $Mysql = new MySqlHelper(); $data = $Mysql->FetchData("select dnum,dprice from sh_store_goods_detail where detailid={$id}"); $num = $data[0]['dnum']; $price = $data[0]['dprice']; echo json_encode(array("msg" => "200", "num" => $num, "price" => $price)); } else { echo json_encode(array("msg" => "110", "num" => '0')); }
$num = $_REQUEST['num']; $sql = "UPDATE sh_store_cart SET snum={$num} WHERE gdetailid={$id} AND userid=" . $userID; $Mysql = new MySqlHelper(); $row = $Mysql->ExecuteSql($sql); if ($row > 0) { echo json_encode(array("code" => "200", "mess" => "修改成功!")); return; } else { echo json_encode(array("code" => "110", "mess" => "修改失败!")); return; } } elseif ($m == 'CHECK') { $strid = $_REQUEST['strid']; $flag = false; if ($strid != '') { $strid = substr($strid, 0, -1); $flag = true; } else { $strid = 0; } $sql = "update sh_store_cart set checkstate=CASE WHEN gdetailid in ({$strid}) THEN 'ON' ELSE 'OFF' END WHERE userid={$userID}"; $Mysql = new MySqlHelper(); $row = $Mysql->ExecuteSql($sql); if ($row > 0) { echo json_encode(array("code" => "200", "mess" => "修改成功!")); return; } else { echo json_encode(array("code" => "110", "mess" => $strid)); return; } }
private function getCategories() { $query = "select * from `MaterialsInCategories` where `material`='{$this->malerial}'"; $mySqlHelper = new MySqlHelper($query); $this->malerialData['categories'] = $mySqlHelper->getAllData(); }
/** * Конструктор. * @param type $tableName - название таблицы локализатора. * @param type $langColumn - название столбца хранящего информацию о языке. * @param type $selectionColumn - название столбца по которому производится отбор данных. * @param type $selectionValue - значение столбца по которому производится отбор данных. * @param type $lang - язык. */ public function __construct($tableName, $langColumn, $selectionColumn, $selectionValue, $lang) { $query_ok = "select * from `Lang` as T1 left join `{$tableName}` as T2\n on T1.`lang` = T2.`{$langColumn}`\n where T1.`lang` = '{$lang}' and T2.`{$selectionColumn}` = '{$selectionValue}'\n limit 0, 1;"; $query_default = "select * from `Lang` as T1 left join `{$tableName}` as T2\n on T1.`lang` = T2.`{$langColumn}`\n where T1.`default` = '1' and T2.`{$selectionColumn}` = '{$selectionValue}' \n limit 0, 1;"; $query_else = "select * from `Lang` as T1 left join `{$tableName}` as T2\n on T1.`lang` = T2.`{$langColumn}`\n where T2.`{$selectionColumn}` = '{$selectionValue}'\n limit 0, 1;"; $this->data = null; $this->keys = null; $mySqlHelper1 = new MySqlHelper($query_ok); $this->data = $mySqlHelper1->getDataRow(0); $this->keys = $mySqlHelper1->getDataKeys(); if ($this->data != null && count($this->data) > 0) { $this->langType = 1; } else { $this->data = null; $this->keys = null; $mySqlHelper2 = new MySqlHelper($query_default); $this->data = $mySqlHelper2->getDataRow(0); $this->keys = $mySqlHelper2->getDataKeys(); if ($this->data != null && count($this->data) > 0) { $this->langType = 0; } else { $this->data = null; $this->keys = null; $mySqlHelper3 = new MySqlHelper($query_else); $this->data = $mySqlHelper3->getDataRow(0); $this->keys = $mySqlHelper3->getDataKeys(); if ($this->data != null && count($this->data) > 0) { $this->langType = 0; } else { $this->langType = -1; } } } }