SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to loop them out and should i create three txt file?

    Now, i want to add some records(`title`,`name`,`content`) to my site by php script. the following way is adding one record:

    Code:
            $comment = Mage::getModel('review/review');
             $comment->setEntityPkValue(147);//product id
             $comment->setTitle("the title");
             $comment->setDetail("the content");                         
             $comment>setNickname("the name");
             $comment->setReviewId($review->getId());
             $comment->setStores(array(Mage::app()->getStore()->getId()));                    
             $comment->save();
             $comment->aggregate();
    when i want to add more records the way i thought is creating three text file(`title`,`name`,`content`). the title text file content like this:

    titleone test,titletwo test,titlthree test,titlefour test

    the name txt file content like this:

    Code:
        name1, name2, name3, name4
    the content like this:

    Code:
        hello,test1.{content}hello,test2.{content}hello,test3.{content}hello,test4.

    then use `file_get_contents() and explode()`. but i don't know how to put those results into

    Code:
         $comment->setTitle("the title");
         $comment->setDetail("the content");                         
         $comment>setNickname("the name");
    then loop them out. thank you

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,326
    Mentioned
    191 Post(s)
    Tagged
    4 Thread(s)
    What you are describing is exactly what a Database is designed to do.
    Is it mandatory you use text files?
    Are you avoiding a Database for some reason?

  3. #3
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    yes, i must be use text files? could you give me some tips to tell me how to do. thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •