Login or Register

RSS IconRecent posts in this topic

avatar
Mark on Jul 13. 2006. 12:23 am
I noticed that if I modify mysql_schema.php I always get an error on install. I believe the problem is that vi (or other editors) add a newline at the end of the file. I tried opening mysql_schema.php, then just saving it (not changing anything), and it grows by exactly one byte. If I then go through the install process I get an error:

---
Step 5: Finish
Installation process:

Connected to database as root@localhost
Database 'acdb3' found
Failed to import database construction. MySQL said: Query was empty
---

Is this a bug or user error?
avatar Staff
Ilija Studen on Jul 13. 2006. 12:25 am
It is a bug, script should be intelligent enough to avoid trying to execute empty query. Thanks for the report.
activeCollab Team Member
avatar
Mark on Jul 13. 2006. 2:18 am
What's the fix? Looks like it would be in the executeMultipleQueries code. I'd like to patch my version if possible.
avatar Staff
Ilija Studen on Jul 13. 2006. 2:31 am
Run a test please:

/**
* Execute multiple queries
* 
* This one is really quick and dirty because I want to finish this and catch
* the bus. Need to be redone ASAP
* 
* This function returns true if all queries are executed successfully
*
* @access public
* @todo Make a better implementation
* @param string $sql
* @param integer $total_queries Total number of queries in SQL
* @param integer $executed_queries Total number of successfully executed queries
* @return boolean
*/
function executeMultipleQueries($sql, &$total_queries, &$executed_queries) {
  if(!trim($sql)) {
    $total_queries = 0;
    $executed_queries = 0;
    return true;
  } // if
  
  // Make it work on PHP 5.0.4
  $sql = str_replace(array("\r\n", "\r"), array("\n", "\n"), $sql);
  
  $queries = explode(";\n", $sql);
  if(!is_array($queries) || !count($queries)) {
    $total_queries = 0;
    $executed_queries = 0;
    return true;
  } // if
  
  $total_queries = count($queries);
  foreach($queries as $query) {
    if(trim($query)) {
      if(@mysql_query(trim($query))) {
        $executed_queries++;
      } else {
        return false;
      } // if
    } // if
  } // if
  
  return true;
} // executeMultipleQueries
activeCollab Team Member
avatar
Mark on Jul 13. 2006. 7:43 pm
Thanks!
Topic is locked. If you have something important to say about issues discussed on this page please write at hi@a51dev.com.

RSS IconRecent posts in this topic