echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
// Setup the database connection to postgres
-$dbServer = 'ds4';
-$dbName = 'brewbakers';
-$dbUser = 'postgres';
-$resetdb = false;
-$rvs = array();
-$homes = array();
+$dbServer = 'ds4';
+$dbName = 'brewbakers';
+$dbUser = 'postgres';
+$resetdb = false;
+$rvs = array();
+$homes = array();
+$amenities = array();
+$amenityData = array();
// Create connection
$connString = "host=$dbServer dbname=$dbName user=$dbUser";
}
$failure = true;
}
- echo '<pre>$amenities: ' . print_r( $amenities, true ) . '</pre>';
+ //echo '<pre>$amenities: ' . print_r( $amenities, true ) . '</pre>';
}
}
// 4. Get amenity member relation data
}
$failure = true;
}
- echo '<pre>$amenityData: ' . print_r( $amenityData, true ) . '</pre>';
+ //echo '<pre>$amenityData: ' . print_r( $amenityData, true ) . '</pre>';
}
}
// 5. Get categories
+// Setup three main level categories
+// Brands, Manufactures, and Classes
+function addNewCategory( $wpdb, $name, $parent )
+{
+ // check to see if the category already exists
+ $catId = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories
+ WHERE name = %s
+ AND parent = %d",
+ $name,
+ $parent
+ )
+ );
+ if ( $catId ) {
+ return $catId;
+ } else {
+ // Add the category
+ $wpdb->insert(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'categories',
+ array(
+ 'name' => $name,
+ 'descr' => '',
+ 'short_descr' => '',
+ 'parent' => $parent
+ ),
+ array(
+ '%s',
+ '%s',
+ '%s',
+ '%d',
+ )
+ );
+ return $wpdb->insert_id;
+ }
+}
+if ( !$failure ) {
+ // Add new main level for Brands
+ $brandId = addNewCategory( $this->wpdb, 'Brands', 0 );
+ echo '<pre>$brandId: ' . print_r( $brandId, true ) . '</pre>';
+ // Get all Brands and add them as sub categories
+ $sql = "
+ SELECT id,name
+ FROM brands
+ ORDER BY id";
+ $res = pg_query( $db, $sql );
+ $rows = pg_num_rows( $res );
+ if ( $rows == 0 ) {
+
+ }
+}
// 6. Get category member relation data