Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    How insert more information's at once time

    I making search engine and inserting information's from Google title,link,description by i am getting slow because i insert title,link,description into datebase (php admin).Is any way that i can insert maybe 100 hundreds or more title,link,description at once time.

  • #2
    New Coder
    Join Date
    Sep 2012
    Location
    Murcia, Spain
    Posts
    22
    Thanks
    0
    Thanked 2 Times in 2 Posts
    A scraping script would probably help you, this script would search google with certain terms and automatically add all results into a database, this is quite easily done in Php.

    Hope that helps,

    Ben
    Freelance and available every day! Check out my portfolio at vnbenny.com

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Use a prepared statement and bind them. The execution phase only needs to pass the data to the dbms to process and not the entire request again.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Mysql

    Scraping script what is that i am not sure how to do it.And bind prepared statement
    i am not sure how to do it.Can you please give to some examples or give to some
    details.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    PHP Code:
    $con = new MySQLi($host$user$pass$db);

    if (
    $stmt $con->prepare("INSERT INTO table VALUES (?)"))
    {
        
    $stmt->bind_param('s'$toInsert);
        while (!
    feof($fp))
        {
            
    $toInsert fgets($fp);
            
    $stmt->execute();
        }
        
    $stmt->close();

    For example. You can see more mysqli_stmt class documentation here: PHP: mysqli_stmt - Manual
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    Pearl_9 (03-13-2014)

  • #6
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    PHP Code:
    $con = new MySQLi($host$user$pass$db);

    if (
    $stmt $con->prepare("INSERT INTO table VALUES (?)"))
    {
        
    $stmt->bind_param('s'$toInsert);
        while (!
    feof($fp))
        {
            
    $toInsert fgets($fp);
            
    $stmt->execute();
        }
        
    $stmt->close();

    For example. You can see more mysqli_stmt class documentation here: PHP: mysqli_stmt - Manual
    DO i have to add this code in code area and make statement copy and paste in datebase.I am not sure how to do it i do have php admin datebase where to add informations.I need details instructions how to do it.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This code won't help you one bit. Its an example of how to use a prepared statement with mysql and PHP. Statements work fantastically for batch insertions.
    The link I provided will take you to the mysqli_stmt class documentation. It is a subsection of the entire mysqli library so you should be able to review all of the documentation for the mysqli classes from there.

    You wouldn't use PHPMyAdmin for this. I don't even know if its designed to work with statements; I would almost anticipate in this day and age it probably has an import option from CSV or XML that would use prepared statements. If your looking from MySQL specific side, you can find the documentation for prepared statements here: MySQL :: MySQL 5.0 Reference Manual :: 13.5 SQL Syntax for Prepared Statements
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #8
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Mysql

    Quote Originally Posted by Fou-Lu View Post
    This code won't help you one bit. Its an example of how to use a prepared statement with mysql and PHP. Statements work fantastically for batch insertions.
    The link I provided will take you to the mysqli_stmt class documentation. It is a subsection of the entire mysqli library so you should be able to review all of the documentation for the mysqli classes from there.

    You wouldn't use PHPMyAdmin for this. I don't even know if its designed to work with statements; I would almost anticipate in this day and age it probably has an import option from CSV or XML that would use prepared statements. If your looking from MySQL specific side, you can find the documentation for prepared statements here: MySQL :: MySQL 5.0 Reference Manual :: 13.5 SQL Syntax for Prepared Statements

    I am really not sure how to do it,even with link which you sent me.If you have some videos or some another link please send me.

  • #9
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    mysql

    Any help please.

  • #10
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    My sql

    Any help...

  • #11
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    my sql

    Any helppppppppppp.

  • #12
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    My sql

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[value-1],[value-2],[value-3],[value-4],[value-5],[value-6])


    I need help with this.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I don't know any video tutorials or anything like that. That's why I sent you the links for the documentation, both at PHP's website for PHP usage and MySQL's website for direct querying.
    The error you have here indicates your query syntax is no good. [] are not used for MySQL btw, those are used for SQLServer. If you have column names like value-1, value-2 etc, you need to use backticks to enclose them. I assume you're using them in a group or order by clause, but that would imply that you're querying and not inserting.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #14
    Regular Coder
    Join Date
    Aug 2013
    Posts
    200
    Thanks
    14
    Thanked 0 Times in 0 Posts

    My sql

    Browse
    Structure
    SQL
    Search
    Insert
    Export
    Import
    Operations
    Triggers




    Those are options i do have if i use insert ,then i can insert just one title,descriptions and keywords.

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    And that's how insertions work. One at a time. You can insert multiple only based off of existing recordsets.

    Back to square one; you can use prepared statements and a bind in order to perform batch insertions. This limits the server request to only the amount of data to modify and not the entire sql string.

    Edit:
    Okay, to be fair you can insert multiple in a single string: INSERT INTO TABLE VALUES (1), (2), (3), but that's not the same as a batch since you still need to logically split everything you want anyway.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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