function get_action($me) { $q = db('select count(me) as c from actions where me=:me and date(time, "unixepoch") between date("now") and date("now", "+1 day") group by me'); $q->bindParam(':me', $me); $q->execute(); $r = $q->fetchAll(PDO::FETCH_COLUMN, 0); if (count($r) === 0) { clear_db($me); } echo json_encode($r); }
<?php include 'simple_html_dom.php'; include 'db.php'; include 'head.php'; // Connect to the database $conn = connect($config); if (!$conn) { die('Problem connecting to the db.'); } include 'content.php'; if (isset($_POST['submit-btn'])) { insert_urls($conn); } if (isset($_POST['showimages'])) { show_images($conn); } if (isset($_POST['cleardb'])) { clear_db($conn); echo '<p id="content">Database cleared</p>'; } include 'footer.php';
clear_db(Order::$table, Customer::$table, 'customer'); // what if Order submited?? // clear clear_db('big_to_small_order', Order::$table, 'small', 'small'); $big_order_ids = Pdb::fetchAll('id', BigOrder::$table); if ($big_order_ids) { foreach ($big_order_ids as $id) { if (!Pdb::exists('big_to_small_order', array('big=?' => $id))) { Pdb::del(BigOrder::$table, array('id=?' => $id)); } } } // clear address 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)); } }