Beispiel #1
0
 function createTables()
 {
     $haserrors = false;
     $filename = dirname(__FILE__) . DS . 'install.sql';
     $handle = fopen($filename, 'r');
     $query = fread($handle, filesize($filename));
     fclose($handle);
     $modelObj =& WYSIJA::get('user', 'model');
     $query = str_replace('CREATE TABLE IF NOT EXISTS `', 'CREATE TABLE IF NOT EXISTS `' . $modelObj->getPrefix(), $query);
     $queries = explode('-- QUERY ---', $query);
     global $wpdb;
     foreach ($queries as $qry) {
         $wpdb->query($qry);
         $error = mysql_error($wpdb->dbh);
         if ($error) {
             $this->notice(mysql_error());
             $haserrors = true;
         }
     }
     $arraytables = array('user_list', 'user', 'list', 'campaign', 'campaign_list', 'email', 'user_field', 'queue', 'user_history', 'email_user_stat', 'url', 'email_user_url', 'url_mail');
     $modelWysija = new WYSIJA_model();
     $missingtables = array();
     foreach ($arraytables as $tablename) {
         if (!$modelWysija->query("SHOW TABLES like '" . $modelWysija->getPrefix() . $tablename . "';")) {
             $missingtables[] = $modelWysija->getPrefix() . $tablename;
         }
     }
     if ($missingtables) {
         $this->error(sprintf(__('These tables could not be created on installation: %1$s', WYSIJA), implode(', ', $missingtables)), 1);
         $haserrors = true;
     }
     if ($haserrors) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 function createTables()
 {
     $filename = dirname(__FILE__) . DS . "install.sql";
     $handle = fopen($filename, "r");
     $query = fread($handle, filesize($filename));
     fclose($handle);
     $modelObj =& WYSIJA::get("user", "model");
     $query = str_replace("CREATE TABLE IF NOT EXISTS `", "CREATE TABLE IF NOT EXISTS `" . $modelObj->getPrefix(), $query);
     $queries = explode("-- QUERY ---", $query);
     $con = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true);
     $haserrors = false;
     if (!$con) {
         die('Could not connect: ' . mysql_error());
         $haserrors = true;
     } else {
         @mysql_select_db(DB_NAME, $con);
         foreach ($queries as $qry) {
             if (!mysql_query($qry, $con)) {
                 $this->notice(mysql_error());
                 $haserrors = true;
             }
         }
     }
     $arraytables = array("user_list", "user", "list", "campaign", "campaign_list", "email", "user_field", "queue", "user_history", "email_user_stat", "url", "email_user_url", "url_mail");
     $modelWysija = new WYSIJA_model();
     $missingtables = array();
     foreach ($arraytables as $tablename) {
         if (!$modelWysija->query("SHOW TABLES like '" . $modelWysija->getPrefix() . $tablename . "';")) {
             $missingtables[] = $modelWysija->getPrefix() . $tablename;
         }
     }
     mysql_close($con);
     if ($missingtables) {
         $this->error(sprintf(__('These tables could not be created on installation: %1$s', WYSIJA), implode(', ', $missingtables)), 1);
         $haserrors = true;
     }
     if ($haserrors) {
         return false;
     }
     return true;
 }