diff -r 3f2dfdb99be4 -r b2fb50d572c7 install/includes/sql_parse.php --- a/install/includes/sql_parse.php Tue Apr 08 20:32:30 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -sql_string = $sql; - } - else - { - if ( file_exists($sql) ) - { - $this->sql_string = @file_get_contents($sql); - if ( empty($this->sql_string) ) - { - throw new Exception('SQL file is blank or permissions are bad'); - } - } - else - { - throw new Exception('SQL file doesn\'t exist'); - } - } - $this->sql_array = false; - $this->tpl_strings = array(); - } - - /** - * Sets template variables. - * @param array Associative array of template variables to assign - */ - - public function assign_vars($vars) - { - if ( !is_array($vars) ) - return false; - $this->tpl_strings = array_merge($this->tpl_strings, $vars); - } - - /** - * Internal function to parse the SQL. - * @access private - */ - - private function parse_sql() - { - $this->sql_array = $this->sql_string; - foreach ( $this->tpl_strings as $key => $value ) - { - $this->sql_array = str_replace("{{{$key}}}", $value, $this->sql_array); - } - - // Build an array of queries - $this->sql_array = explode("\n", $this->sql_array); - - foreach ( $this->sql_array as $i => $sql ) - { - $query =& $this->sql_array[$i]; - $t = trim($query); - if ( empty($t) || preg_match('/^(\#|--)/i', $t) ) - { - unset($this->sql_array[$i]); - unset($query); - } - } - unset($query); - - $this->sql_array = array_values($this->sql_array); - $this->sql_array = implode("\n", $this->sql_array); - $this->sql_array = explode(";\n", $this->sql_array); - - foreach ( $this->sql_array as $i => $sql ) - { - $query =& $this->sql_array[$i]; - if ( substr($query, ( strlen($query) - 1 ), 1 ) != ';' ) - { - $query .= ';'; - } - } - unset($query); - } - - /** - * Returns the parsed array of SQL queries. - * @param bool Optional. Defaults to false. If true, a parse is performed even if it already happened. - * @return array - */ - - public function parse($force_reparse = false) - { - if ( !$this->sql_array || $force_reparse ) - $this->parse_sql(); - return $this->sql_array; - } -} - -?>