function RetrieveCoupons($UserId) { $con = MysqlConnect(); $query = "SELECT * FROM affiliateplus_coupon\nwhere account_id = {$UserId}\nORDER BY affiliateplus_coupon.program_id DESC"; $result = mysqli_query($con, $query); $coupons = array(); while ($coupon = mysqli_fetch_object($result)) { array_push($coupons, $coupon); } return $coupons; }
function TreeRetriver($AffiliateId) { $con = MysqlConnect(); $AffiliateTree = "SELECT affiliateplus_account.account_id as lev0, tabla.lev1, tabla.lev2, tabla.lev3, tabla.lev4,\n\t\ttabla.lev5,tabla.lev6,tabla.lev7,tabla.lev8,tabla.lev9,tabla.lev10,\n\t\ttabla.lev11,tabla.lev12,tabla.lev13,tabla.lev14,tabla.lev15,tabla.lev16,tabla.lev17,tabla.lev18,tabla.lev19,tabla.lev20,\n\t\ttabla.lev21,tabla.lev22,tabla.lev23,tabla.lev24,tabla.lev25,tabla.lev26,tabla.lev27,tabla.lev28,tabla.lev29,tabla.lev30,\n\t\ttabla.lev31,tabla.lev32,tabla.lev33,tabla.lev34,tabla.lev35,tabla.lev36,tabla.lev37,tabla.lev38,tabla.lev39,tabla.lev40,\n\t\ttabla.lev41,tabla.lev42,tabla.lev43,tabla.lev44,tabla.lev45,tabla.lev46,tabla.lev47,tabla.lev48,tabla.lev49,tabla.lev50\n\t\tFROM\n\n\n\t\taffiliateplus_account left join\n\n\n\n\t\t(SELECT\n\t\t t1.tier_id AS lev1, t2.tier_id AS lev2, t3.tier_id AS lev3, t4.tier_id AS lev4 , t5.tier_id AS lev5, t6.tier_id AS lev6, t7.tier_id AS lev7, t8.tier_id AS lev8, t9.tier_id AS lev9, t10.tier_id AS lev10,\n\t\t t11.tier_id AS lev11, t12.tier_id AS lev12, t13.tier_id AS lev13, t14.tier_id AS lev14 , t15.tier_id AS lev15, t16.tier_id AS lev16, t17.tier_id AS lev17, t18.tier_id AS lev18, t19.tier_id AS lev19, t20.tier_id AS lev20,\n\t\tt21.tier_id AS lev21, t22.tier_id AS lev22, t23.tier_id AS lev23, t14.tier_id AS lev24 , t25.tier_id AS lev25, t26.tier_id AS lev26, t27.tier_id AS lev27, t28.tier_id AS lev28, t29.tier_id AS lev29, t30.tier_id AS lev30,\n\t\tt31.tier_id AS lev31, t32.tier_id AS lev32, t33.tier_id AS lev33, t14.tier_id AS lev34 , t35.tier_id AS lev35, t36.tier_id AS lev36, t37.tier_id AS lev37, t38.tier_id AS lev38, t39.tier_id AS lev39, t40.tier_id AS lev40,\n\t\tt41.tier_id AS lev41, t42.tier_id AS lev42, t43.tier_id AS lev43, t14.tier_id AS lev44 , t45.tier_id AS lev45, t46.tier_id AS lev46, t47.tier_id AS lev47, t48.tier_id AS lev48, t49.tier_id AS lev49, t50.tier_id AS lev50,\n\n\n\n\n\t\tt1.toptier_id as buscado\n\n\t\tFROM affiliatepluslevel_tier AS t1\n\n\t\tLEFT JOIN affiliatepluslevel_tier AS t2 ON t2.toptier_id = t1.tier_id\n\n\t\tLEFT JOIN affiliatepluslevel_tier AS t3 ON t3.toptier_id = t2.tier_id\n\n\t\tLEFT JOIN affiliatepluslevel_tier AS t4 ON t4.toptier_id = t3.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t5 ON t5.toptier_id = t4.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t6 ON t6.toptier_id = t5.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t7 ON t7.toptier_id = t6.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t8 ON t8.toptier_id = t7.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t9 ON t9.toptier_id = t8.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t10 ON t10.toptier_id = t9.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t11 ON t11.toptier_id = t10.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t12 ON t12.toptier_id = t11.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t13 ON t13.toptier_id = t12.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t14 ON t14.toptier_id = t13.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t15 ON t15.toptier_id = t14.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t16 ON t16.toptier_id = t15.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t17 ON t17.toptier_id = t16.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t18 ON t18.toptier_id = t17.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t19 ON t19.toptier_id = t18.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t20 ON t20.toptier_id = t19.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t21 ON t21.toptier_id = t20.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t22 ON t22.toptier_id = t21.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t23 ON t23.toptier_id = t22.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t24 ON t24.toptier_id = t23.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t25 ON t25.toptier_id = t24.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t26 ON t26.toptier_id = t25.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t27 ON t27.toptier_id = t26.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t28 ON t28.toptier_id = t27.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t29 ON t29.toptier_id = t28.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t30 ON t30.toptier_id = t29.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t31 ON t31.toptier_id = t30.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t32 ON t32.toptier_id = t31.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t33 ON t33.toptier_id = t32.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t34 ON t34.toptier_id = t33.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t35 ON t35.toptier_id = t34.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t36 ON t36.toptier_id = t35.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t37 ON t37.toptier_id = t36.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t38 ON t38.toptier_id = t37.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t39 ON t39.toptier_id = t38.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t40 ON t40.toptier_id = t39.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t41 ON t41.toptier_id = t40.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t42 ON t42.toptier_id = t41.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t43 ON t43.toptier_id = t42.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t44 ON t44.toptier_id = t43.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t45 ON t45.toptier_id = t44.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t46 ON t46.toptier_id = t45.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t47 ON t47.toptier_id = t46.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t48 ON t48.toptier_id = t47.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t49 ON t49.toptier_id = t48.tier_id\n\t\tLEFT JOIN affiliatepluslevel_tier AS t50 ON t50.toptier_id = t49.tier_id\n\n\n\n\n\t\tWHERE t1.toptier_id = {$AffiliateId}\n\n\n\n\t\t) as tabla on (buscado = affiliateplus_account.account_id)\n\n\n\n\n\n\t\tWHERE affiliateplus_account.account_id = {$AffiliateId} "; $Tree = mysqli_query($con, $AffiliateTree); $data = array(); while ($row = mysqli_fetch_array($Tree)) { array_push($data, $row); } $normalizedRows = array(); foreach ($data as $tree => $branch) { foreach ($branch as $key => $value) { if (!is_int($key) && !is_null($value)) { $levelNumber = filter_var($key, FILTER_SANITIZE_NUMBER_INT); array_push($normalizedRows, array("id_group" => $tree + 1, "Levels" => $levelNumber, "Account_id" => $value)); } if (is_int($key)) { unset($data[$tree][$key]); } if (is_null($value)) { unset($data[$tree][$key]); } } } return $normalizedRows; }
//!Андрей Б., ем не угодил класс waDbResultSelect? $dbhost = "localhost"; $dbname = "sela-test1"; $dbuser = "******"; $dbpass = "******"; $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass); if (!$dbcnx) { die("Соединение с бд не установлено"); } if (!@mysql_select_db($dbname, $dbcnx)) { die("БД не найдена"); } mysql_query("set names utf8"); return $dbcnx; } MysqlConnect(); function db_query($sql) { global $dbcnx; $k = 0; while (!@($res = mysql_query($sql) or die(mysql_error() . " in " . $sql))) { if ($k > 5) { die; } $k++; } return $res; } class shopFrontendProductAction extends shopFrontendAction { /**