Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Export Via Sqlyob / Import Via Php?

forums forums Export Via Sqlyob / Import Via Php?

  • This topic is empty.
Viewing 3 reply threads
  • Author
    Posts
    • #9548
      sloppyboy
      Member

      Hello,

      I'm wondering if there is any possible way to take the structure/data export .sql files that SQLYog generates and read/execute it as a script via PHP code. Is this possible?

      If this is not possible, I would find it VERY helpful if a feature was added to SQLYog Enterprise that would allow you to export the db structure and/or data into a php file that you could run from your php server.

      I realize that you can import the .sql files from SQLYog into the db but I'm trying to build an installation script for an application that will be installed on many different web servers. And as far as I know, in php you have to execute one statement at a time which will be a HUGE headache if I have to strip each statement separately out of the .sql file and execute it individually.

      Any ideas are appreciated. Thanks!

      Tommy

    • #20920
      peterlaursen
      Participant

      QUOTE
      … into a php file that you could run from your php server

      What you need is then to generate a PHP statment like

      CODE
      $goforit = mysql_query('here goes 1st query') or die (mysql_error());

      $goforit = mysql_query('here goes 2st query') or die (mysql_error());

      etc …

      Now if you 'search and replace' the SQL generated by SQLyog in an editor and replace

      CODE
      ;

      with

      CODE
      ;') or die (mysql_error());

      $goforit = mysql_query('

      it will be 95%. You will need to add the connection string and edit first and last statement. But it is a reasonably good idea of yours I think. One more export option: 'export as PHP-script'.

    • #20921
      sloppyboy
      Member

      Thanks for your reply. I think for now I'm going to write a script that parses through a directory of .sql files generated by SQLYog and throws each individual statement into an array to be executed on the db in the right order.

      This way I'll be able to generate multiple .sql files from SQLYog, put them in a single directory, and the script will be able to pick them up in sequential order, parse through them, and apply all sql statements in the right order. This is going to be useful for dropping hotfix db schema updates for an application where you would have multiple .sql files based on bug fixes or schema changes in between application releases.

      Tommy

    • #20922
      Ritesh
      Member

      This is a nice idea.

      In the meantime, you can use my_strtok() function available in SQLyogTunnel.php for tokenising the queries.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.