Esempio n. 1
0
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_account")) {
    //- create tables if not exits
    echo " - Create table 'wechat_account' ";
    echo WechatAccount::createTableIfNotExist() ? "success\n" : "fail\n";
}
//-- WechatArticle:Clear cache
if ($command == "cc") {
    if ($arg1 == "all" || $arg1 == "wechat_account") {
        echo " - Drop table 'wechat_article' ";
        echo WechatArticle::dropTable() ? "success\n" : "fail\n";
    }
}
//-- WechatArticle:Import DB
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_article")) {
    //- create tables if not exits
    echo " - Create table 'wechat_article' ";
    echo WechatArticle::createTableIfNotExist() ? "success\n" : "fail\n";
}
//-- WechatAccountUser:Clear cache
if ($command == "cc") {
    if ($arg1 == "all" || $arg1 == "wechat_account") {
        echo " - Drop table 'wechat_account_user' ";
        echo WechatAccountUser::dropTable() ? "success\n" : "fail\n";
    }
}
//-- WechatAccountUser:Import DB
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_account_user")) {
    //- create tables if not exits
    echo " - Create table 'wechat_account_user' ";
    echo WechatAccountUser::createTableIfNotExist() ? "success\n" : "fail\n";
}
 public function delete()
 {
     $rtn = parent::delete();
     // delete extra relationship for wechat_account_user if existed
     if ($rtn) {
         $user = MySiteUser::getCurrentUser();
         $wechat_account_user = WechatAccountUser::findbyCombo($this->getAccountId(), $user->getId());
         if ($wechat_account_user) {
             $wechat_account_user->delete();
         }
     }
     // check if there is any other users subscribing this wechat_account, if no, we delete it
     if ($rtn) {
         $wechat_account_users = WechatAccountUser::findByAccountId($this->getAccountId());
         if (sizeof($wechat_account_users) == 0) {
             $wechat_account = WechatAccount::findById($this->getAccountId());
             $wechat_account->delete();
         }
     }
     return $rtn;
 }