if (!empty($projects)) { $query .= "(`customized_type`='Project' AND `customized_id` IN ({$projects})) OR "; } $query .= "FALSE"; $result = mysql_query($query) or die("Query custom_values failed: " . mysql_error() . "\n"); $custom_values = ""; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $custom_values .= $row[0] . ","; //echo "custom_values: {$row[0]}\n"; } $custom_values = substr($custom_values, 0, -1); } //Instantiate the SQL_Export class $e = new SQL_Export($server, $username, $password, $db); // Define the database tables $tables = $e->get_tables(); // Open the output file $database_file = "database_{$userId}.sql"; $fp = fopen($database_file, 'w'); # Now UTF-8 - Add byte order mark fwrite($fp, pack("CCC", 0xef, 0xbb, 0xbf)); //Run the export foreach ($tables as $t) { $header = $e->create_header($t); $data = ""; switch ($t) { case 'attachments': if (!empty($attachments)) { $data = $e->get_data($t, "`id` IN ({$attachments})"); } break;