array_filter( ["prop1" => $return['prop1'], "par1" => $return['par1'], "min1" => $return['min1'], "max1" => $return['max1']] ), "Prop2" => array_filter( ["prop2" => $return['prop2'], "par1" => $return['par2'], "min1" => $return['min2'], "max1" => $return['max2']] ), "Prop3" => array_filter( ["prop3" => $return['prop3'], "par1" => $return['par3'], "min1" => $return['min3'], "max1" => $return['max3']] ), "Prop4" => array_filter( ["prop4" => $return['prop4'], "par1" => $return['par4'], "min1" => $return['min4'], "max1" => $return['max4']] ), "Prop5" => array_filter( ["prop5" => $return['prop5'], "par1" => $return['par5'], "min1" => $return['min5'], "max1" => $return['max5']] ), "Prop6" => array_filter( ["prop6" => $return['prop6'], "par1" => $return['par6'], "min1" => $return['min6'], "max1" => $return['max6']] ), "Prop7" => array_filter( ["prop7" => $return['prop7'], "par1" => $return['par7'], "min1" => $return['min7'], "max1" => $return['max7']] ), "Prop8" => array_filter( ["prop8" => $return['prop8'], "par1" => $return['par8'], "min1" => $return['min8'], "max1" => $return['max8']] ), "Prop9" => array_filter( ["prop9" => $return['prop9'], "par1" => $return['par9'], "min1" => $return['min9'], "max1" => $return['max9']] ), "Prop10" => array_filter( ["prop10" => $return['prop10'], "par1" => $return['par10'], "min1" => $return['min10'], "max1" => $return['max10']] ) ]); // need par, min, max value for each prop // // // ( Also need func1 and val1 for each prop ) // // // // // for each prop, get stat $counter = 1; foreach ($props as $key => $val) { // val = Prop1,Prop2 etc. // for each propr, get all 7 stats in ISC $sql = "SELECT stat1 FROM `properties` WHERE `code` = '{$val['prop' . $counter]}'"; $props[$key]['stat'] = PDO_FetchRow($sql); if (!empty($props[$key]['stat'])){ $props[$key]['stat'] = array_filter($props[$key]['stat']); } $counter++; } //ddump($props); $counter = 1; //each stat now goes into getIscStrings foreach ($props as $k => $v) { //ddump($v); $props[$k]['desc'] = $this->getIscStrings($v['prop' . $counter]); $counter++; } // SELECT * FROM strings WHERE `Key`='ModStr3a' returns always Amazon Skills // todo: put values in params, so I can get generated string for that prop $counter = 1; foreach ($props as $k => $v) { // for each property Prop1 Prop2 // $sql = "SELECT val$counter,func$counter FROM `properties` WHERE `code`=\"{$return['prop' . $counter]}\""; // $funcval = PDO_FetchRow($sql); // // var_dump($funcval); $params = [ 'string1' => $v['desc']['string1'], 'string2' => $v['desc']['string2'], 'descfunc' => $v['desc']['descfunc'], 'descval' => $v['desc']['descval'], "prop" => $return['prop' . $counter], "par" => $return['par' . $counter], "min" => $return['min' . $counter], "max" => $return['max' . $counter], // "val1" => $funcval['val1'], // "func1" => $funcval['func1'] // 'item' => $return ]; /* * getDesc should process string1, not file guide copy pasta * */ if (!empty($v['desc'])) { require_once 'D2ItemDesc.php'; $idesc = new D2ItemDesc(); $props[$k]['string'][] = ($idesc->getDesc($params)); } $counter++; } $return['props'] = $props; $sqlArmor = "SELECT * FROM armor WHERE code='{$res['code']}'"; $sqlMisc = "SELECT * FROM misc WHERE code='{$res['code']}'"; $sqlWeapons = "SELECT * FROM weapons WHERE code='{$res['code']}'"; $baseItemInfo = PDO_FetchRow($sqlArmor); $uTable = "armor"; if (empty($baseItemInfo)) { $baseItemInfo = PDO_FetchRow($sqlMisc); } if (empty($baseItemInfo)) { $baseItemInfo = PDO_FetchRow($sqlWeapons); } $return['baseItemInfo'] = $baseItemInfo; if(!empty($baseItemInfo)){ $return['baseItemInfo'] = array_filter($baseItemInfo); } if(!$doc){ header('Content-Type: application/json'); return json_encode($return, JSON_INVALID_UTF8_IGNORE | JSON_PRETTY_PRINT); } else { return $return; } } // function getIscStringsX($iscStat) { //// $sql = " ////SELECT s1.String as string1, s2.String as string2, descfunc, descval //// FROM itemstatcost as i //// LEFT JOIN strings AS `s1` ON `i`.descstrpos = `s1`.`Key` //// LEFT JOIN strings AS `s2` ON `i`.DescStr2 = `s2`.`Key` //// WHERE `Stat` = '$iscStat' ////"; // // // $sql = "SELECT String as string1 // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat'"; // $string1 = PDO_FetchOne($sql); // // $sql = "SELECT String as string2 // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.DescStr2 = `s`.`Key` // WHERE `Stat` = '$iscStat'"; // $string2 = PDO_FetchOne($sql); // // $sql = "SELECT descfunc // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat'"; // $descfunc = PDO_FetchOne($sql); // // $sql = "SELECT descval // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat'"; // $descval = PDO_FetchOne($sql); // // // //ddump(); // // return ["string1"=>$string1, "string2"=>$string2, "descfunc"=>$descfunc, "descval"=>$descval]; // } // // function getIscStringsXXX($iscStat) { // $sql = " //SELECT // ( // SELECT String // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat' // ) //AS string1, // ( // SELECT String // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.DescStr2 = `s`.`Key` // WHERE `Stat` = '$iscStat' // ) //AS string2, //( // SELECT descfunc // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat' // ) //AS descfunc, //( // SELECT descval // FROM itemstatcost as i // LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key` // WHERE `Stat` = '$iscStat' // ) //AS descval //"; // // // return PDO_FetchRow($sql); // } public function getIscStrings($iscStat) { $sql = "SELECT p.`code` as prop, p.stat1, i.descstrpos, i.descstr2, i.descfunc, i.descval, s1.String as string1, s2.String as string2 FROM properties as p LEFT JOIN itemstatcost as i ON p.stat1 = i.Stat LEFT JOIN strings as s1 ON i.descstrpos = s1.Key LEFT JOIN strings as s2 ON i.descstr2 = s2.Key WHERE p.code = \"$iscStat\" "; return PDO_FetchRow($sql); } public function genDoc($itemData){ } }