Jump to content

bores_escalovsk

Members
  • Posts

    25
  • Joined

  • Last visited

bores_escalovsk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php $db = new PDO('mysql:host=localhost;dbname=wordpress', 'root',''); //---------prepare $delete3 = $db->prepare("DELETE FROM wp_term_relationships WHERE object_id=:id"); $delete2 = $db->prepare("DELETE FROM wp_posts WHERE ID=:id"); $delete = $db->prepare("DELETE FROM wp_postmeta WHERE post_id=:id"); $select = $db->prepare("SELECT post_id FROM reference WHERE x_id=?"); $delete->bindValue(':id', $id, PDO::PARAM_STR); $delete2->bindValue(':id', $id, PDO::PARAM_STR); $delete3->bindValue(':id', $id, PDO::PARAM_STR); //---------- echo 'conected-----'; { $delfeed = '';} $array = explode(',',$delfeed); foreach($array as $deadman){ $select->execute(array($deadman)); $row = $select->Fetch(PDO::FETCH_ASSOC); $id = $row['post_id']; if ($id == null){} else { echo "$id"."\n"; $delete->execute(); $delete2->execute(); $delete3->execute(); } $id++; } echo 'done!'; ?> its a simple delete script but it doesnt delete, it does print the right $id's witch means is working till there but delete goes bananas,double checked table names ,colums... tryied working with question mark place holders insted of bind parameter but nothing
  2. as always i screwed up everything(sorry) , thanks for the patience , i will follow the tips and figure out the rest my self
  3. php obi-wan kenobi i will solve that but how can is solve my ram problems , seriously is using more than 2gb of ram ...run line by line or something
  4. <?php $db2 = new PDO('mysql:host=localhost; dbname=dbname1;', 'root', ''); $db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $sql = "INSERT INTO wp2_posts(post_content) VALUES (:parameter)"; $content = "#####$tags##### %%%%%$category%%%%% !!!!!$title!!!!!"; addslashes($content); foreach($db2->query('SELECT * FROM dbname2') as $row) { $href = $row['href']; $title = $row['title']; $thumb = $row['thumb']; $tags = $row['tags']; $category = $row['category']; $q = $db2->prepare($sql); $q->execute(array(':parameter'=>$content)); } ?> so final result should be this ?? .-. im confused, should i dump the variables at the end of the loop or im talking non sense ?
  5. the code works with 10 lines but when i jump to a million it just go crazy on ram memory... any help? <?php $db2 = new PDO('mysql:host=localhost; dbname=dbname1;', 'root', ''); $db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); foreach($db2->query('SELECT * FROM dbname2') as $row) { $href = $row['href']; $title = $row['title']; $thumb = $row['thumb']; $tags = $row['tags']; $category = $row['category']; $content = " file=$strfinal image=$thumb]\"; [/php] #####$tags##### %%%%%$category%%%%% !!!!!$title!!!!!"; addslashes($content); $sql = "INSERT INTO wp2_posts(post_content) VALUES (:parameter)"; $q = $db2->prepare($sql); $q->execute(array(':parameter'=>$content)); } ?>
  6. thanks a freaking lot, but how do i modify what i am writing in database 2 in this way?
  7. sorry by the extreme n00b question but i can insert and select from different databases in the same query???? mind blow
  8. im modifying data in the process , i tried with out the limit 1 but database 1 got many many rows and i eventually run out of memory
  9. finally got some time to code anyway i cant figure out why this doesnt work, i think its an error in my logic... <?php $db = new PDO('mysql:host=localhost; dbname=test;', 'root', ''); $db2 = new PDO('mysql:host=localhost; dbname=test2;', 'root', ''); foreach($db->query('SELECT * FROM database1 LIMIT 1') as $row) { $thing1 = $row['COL 1']; $thing2 = $row['COL 2']; $thing3 = $row['COL 4']; $thing4 = $row['COL 6']; $thing5 = $row['COL 7']; $content = "\"big text with $things\""; addslashes($content); $db2->exec("INSERT INTO database2(col1,col2,col3) VALUES ('$thing1','text','$content')"); } ?> my foreach command should read all lines from database one and write one by one on database two? thx in advance
  10. just for the record , i solved by using dbforge and transforming the csv in a mysql table, way easier than what i was trying to do. thank you all guys
  11. this is worst than the time i learned regex ,-, i was trying to do that, but the file have 2gb , not the easyest thing
  12. its a part of my code , the echo is only for testing ...the code needs to read 1 line per run ,return the value as a string and at the next run read the next line.
  13. if i take out the counter it will read one line only ? but on next run it will read same line?
  14. i have to read a single line from a csv, its a really big file and i only need one column. i need the response to be a string ,i made a search and found the following code but i dont have any idea how to get a single line from a single string per run . <?php $row = 1; //open the file if (($handle = fopen("file.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.