Example #1
0
 public static function has($username)
 {
     return Pdb::exists(self::$table, array('name=?' => $username));
 }
Example #2
0
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));
        }
    }
}
Example #3
0
File: User.php Project: name3/cheng
 public static function check($username, $password)
 {
     return Pdb::exists(self::$table, array('name=?' => $username, 'password=?' => md5($password)));
 }
Example #4
0
 public function exists()
 {
     $self = get_called_class();
     return Pdb::exists($self::$table, $this->selfCond());
 }
Example #5
0
File: test.php Project: name3/cheng
// 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));
        }
    }
}
// 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;