Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Create db table if it doesn't exist

  • Loading branch information...
commit 7557e1f368861365912406fe6b3f87e4fd9c0705 1 parent e9b9a3f
John P. Bloch authored

Showing 1 changed file with 38 additions and 2 deletions. Show diff stats Hide diff stats

  1. +38 2 quick-wp
40 quick-wp
@@ -82,10 +82,46 @@ EOF;
82 82 }
83 83
84 84 $mysql = mysql_connect( 'localhost', 'test', 'test' );
85   -mysql_select_db( 'test', $mysql );
  85 +
  86 +if( !$mysql )
  87 +{
  88 + echo <<<EOF
  89 +Could not connect to database server!
  90 +Terminating...
  91 +
  92 +EOF;
  93 + exit(1);
  94 +}
  95 +
  96 +$database_exists = mysql_select_db( 'test', $mysql );
  97 +
  98 +if( !$database_exists )
  99 +{
  100 + echo <<<EOF
  101 +Could not select database!
  102 +Terminating...
  103 +
  104 +EOF;
  105 + exit(1);
  106 +}
  107 +
  108 +$tables = mysql_query( "SHOW TABLES LIKE 'quicktestSites';", $mysql );
  109 +
  110 +if( mysql_num_rows( $tables ) === 0 )
  111 +{
  112 + $create = "CREATE TABLE `quicktestSites` (
  113 + `id` bigint(10) unsigned NOT NULL AUTO_INCREMENT,
  114 + `url` varchar(100) NOT NULL DEFAULT '',
  115 + `path` varchar(100) NOT NULL DEFAULT '',
  116 + `name` varchar(100) NOT NULL DEFAULT '',
  117 + `status` varchar(40) NOT NULL DEFAULT '',
  118 + PRIMARY KEY (`id`)
  119 + ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
  120 + mysql_query( $create, $mysql );
  121 +}
86 122
87 123 $query = "SELECT * FROM `quicktestSites` WHERE status = 'pending' ORDER BY id ASC LIMIT 1;";
88   -$pending_site = mysql_query( $query );
  124 +$pending_site = mysql_query( $query, $mysql );
89 125
90 126 if( mysql_num_rows( $pending_site ) === 1 )
91 127 {

0 comments on commit 7557e1f

Please sign in to comment.
Something went wrong with that request. Please try again.