public function emptyCart() { Pdb::del(Cart::$table, array('customer' => $this->id)); }
function clear_relation_db($main_table, $ref_table, $relation_table = null, $key_main = null, $key_ref = null) { if ($relation_table === null) { $relation_table = $main_table . '_' . $ref_table; } if ($key_main === null) { $key_main = $main_table; } if ($key_ref === null) { $key_ref = $ref_table; } $all = Pdb::fetchAll('*', $relation_table); if ($all === false) { Pdb::del($ref_table); return; } // del in relation table foreach ($all as $info) { if (!Pdb::exists($main_table, array('id=?' => $info[$key_main]))) { Pdb::del($relation_table, array($key_main . '=?' => $info[$key_main])); } } // del in ref table $all = Pdb::fetchAll('*', $ref_table); if (empty($all)) { return; } foreach ($all as $info) { $id = $info['id']; if (!Pdb::exists($relation_table, array($key_ref . '=?' => $id))) { Pdb::del($ref_table, array('id=?' => $id)); } } }
public function delProduct($arg) { $prds = is_array($arg) ? $arg : array($arg); foreach ($prds as $prd) { if ($prd instanceof Product) { $id = $prd->id; } elseif (is_numeric($prd)) { $id = $prd; } else { d($arg); throw new Exception("not good arg for del Product"); } Pdb::del(Product::$table, array('id=?' => $id)); } }
public function del(Order $order) { Pdb::del(self::$table, array('customer=?' => $this->owner_id, 'order=?' => $order->id)); }
clear_relation_db(Customer::$table, Address::$table); // clear user log clear_db(UserLog::$table, Customer::$table, 'subject'); // clear account clear_11_db(Customer::$table, Account::$table); // clear account log clear_1m_db(Account::$table, AccountHistory::$table); // clear price_data $pds = Pdb::fetchAll('id', PriceData::$table); if ($pds) { $tbl = Order::$table; foreach ($pds as $id) { $cond1 = array('factory_price = ?' => $id); $cond2 = array('customer_price = ?' => $id); if (!Pdb::exists($tbl, $cond1) && !Pdb::exists($tbl, $cond2)) { Pdb::del(PriceData::$table, array('id = ?' => $id)); } } } // clear stone clear_11_db(Order::$table, Stone::$table); if (_get('exit')) { echo '<script src="static/hide.js"></script>'; echo '<div class="conclusion pass">All Clear!</div>'; exit; } $all_pass = true; // case 1 autoload begin_test(); $id = 101; $model = new Model($id);