php - Code setting item price to 0 -


alright, these 2 functions refuse work reason , cannot figure out why. work fine if used outside of active database (i'ved tested , testing right now) reason second they're getting information database, 0 out price that's supposed updated; eg price should go say, 20 dollars 4, goes 0 , next time updates goes next number in line.

private function updateprice($iid, $price, $purchased) {     if($price >= 0)     {         $price = abs($price);     }     else     {         $price = $this->getitemstats($iid);         $price = abs($price['base']);     }         $sql = "update store set item_price = :price, available = available-:purchased  iid = :iid";         $que = $this->db->prepare($sql);         $que->bindparam('price', $price);         $que->bindparam('iid', $iid);         $que->bindparam('purchased', $purchased);         try{$que->execute(); if($que) { return true; } else { echo "fuck"; exit; } }catch(pdoexception $e){echo $e->getmessage(); exit;} } function getsupplydemand($purchased, $iid) {     $sql = "select available, number, item_base_price, iid store iid = :iid";     $que = $this->db->prepare($sql);     $que->bindparam('iid', $iid);     try{ $que->execute();         if($que)         {             while($row = $que->fetch())             {                 $quantity =$row[0];                 $supply = $row[1];                 $price = $row[2];                 $iid = $row[3];                 $price = abs(($price * $purchased)*($quantity - $supply)/.25);                     if($this->updateprice($iid, $price, $purchased))                     {                         return true;                     }                     else                     {                         echo "somethign went wrong";                         exit;                     }             }         }     }catch(pdoexception $e){}    } 

i solved problem. once again simple overthought. wasn't calling functions in proper order therefore number , available same , removed 1 cancling out whole price.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -