function _DatabaseHandler::z__get_table_transfer_data_string

5.x _DatabaseHandler.php _DatabaseHandler::z__get_table_transfer_data_string($table_name, $table_structure, $where_clause = "")

File

classes/_DatabaseHandler.php, line 248

Class

_DatabaseHandler

Code

function z__get_table_transfer_data_string($table_name, $table_structure, $where_clause = "") 
 {
  // This function will return a string of all the data
  // in a particular table, formatted with delimeters.
  // %R~ separates rows, %C~ separates columns.
  // We expect the tableStructure to be a csv of the
  // column names.
  $rtn = "";


  $res = mysql_query("select $table_structure from $table_name $where_clause") or die_and_mail(mysql_error());
  while ($cur = mysql_fetch_row($res)) 
   {
    $new_row = "";

    foreach ($cur as $key => $value) 
     { // put all the values returned together...
      $new_row .= $value . "%C~";
    }
    // Remove last %C%...
    $new_row = substr($new_row, 0, -3);

    // Add it to the rtn...
    $rtn .= $new_row . "%R~";

  }

  // Remove the last %R%...
  $rtn = substr($rtn, 0, -3);

  return $rtn;
}