php - Drupal DB : Have to move some data from one table to another by cheking the condition at remote server..! -


i working portal, there content type. front end developer made portal added cck field file attachment & there file attachment field given core. won't go discuss why did don't know.

now have removed cck field & if remove directly, loose data uploaded field remove table of it.

so trying replace value cck field table default upload table & update filepath in files table..so come in view attached files.

because not @ php or mysql seeking guys..

here basic code, have written...please suggest correction & please tell me able connect remote server db in doing -

<?php  mysql_connect("http://edlabs.in/connect:22","connect",""); mysql_select_db("connect");  for($i=0; $i<=1; $i++){      $fid_cck = array(mysql_query("select field_upload_doc_fid content_field_upload_doc field_upload_doc_list > 0"));     $fid_core = array(mysql_query("select fid upload"));      foreach($fid_cck $fid_cck_value){          foreach($fid_core $fid_core_value)         {             if($fid_cck_value != $fid_core_value){                  $file_name = mysql_query("select filename files fid = $fid_cck");                 $nid_cck = mysql_query("select nid field_upload_doc_fid fid = $fid_cck");                 $vid_cck = mysql_query("select vid field_upload_doc_fid fid = $fid_cck");                  mysql_query("insert upload values('$fid_cck', '$nid_cck', '$vid_cck', '$file_name', 1, 0)");                  $filepath = array(mysql_query("select filepath files fid = $fid_cck"));                  $new_filepath = str_replace("/background_docs", "", $filepath);                  mysql_query("update files set filepath=$new_filepath fid = $fid_cck");              }         }     }   } ?> 

i have solved problem following these steps-

  1. created db same name portal @ local phpmyadmin.
  2. exported 3 table named content_field_upload_doc, files & upload db of portal.
  3. wrote custom php code mysql query make query , find diff of files in content_field_upload_doc not in upload table & picked name of table files.(i giving code below).
  4. ran code on wamp , echoed insert query.
  5. copied query & executed sql on phpmyadmin @ portal db.
  6. copied files previous used folder inside public folder & pasted default public folder.
  7. removed cck field content type...and it's done..!

    die('could not connect: ' . mysql_error()); } else{
    mysql_select_db("connect");  $rs_fudl = mysql_query("select vid, nid, field_upload_doc_fid content_field_upload_doc field_upload_doc_list > '0'"); while($rs_fudl_row = mysql_fetch_array($rs_fudl)) {      $fid_fudl = $rs_fudl_row['field_upload_doc_fid'];      $rs_file = mysql_query("select filename,filepath files fid = '$fid_fudl'");      //echo mysql_num_rows($rs_file)."<br />";      while($rs_file_row = mysql_fetch_array($rs_file)){              $rs_upload = mysql_query("select * upload fid='".$fid_fudl."'");              if ( mysql_num_rows($rs_upload) == 0) {              /*  $new_filepath = str_replace("/background_docs", "", $rs_file_row['filepath']);                  $filepath = $new_filepath;             */                 $filename = $rs_file_row['filename'];                 $vid_fudl = $rs_fudl_row['vid'];                 echo "<br />";                  $nid_fudl = $rs_fudl_row['nid'];                 echo "<br />";                  echo "insert upload values ('$fid_fudl','$nid_fudl', '$vid_fudl', '$filename','1', '0');" ;                 echo "<br />";             //  echo "update files set filepath= '$filepath' fid = '$fid_fudl';";                   }     } } mysql_close($con); 
    } ?>

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -