Why does asterisk appear at the END of a statement???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tarek01
    New Member
    • Feb 2010
    • 14

    Why does asterisk appear at the END of a statement???

    This was taken from a working model. Inside the heredoc (<<<) an asterisk appears at the end of each MySQL statement after the semicolon (lines 4 and 10). The actual script contains several statements and it appears after each one, so it's unlikely it was unintentional. Does anyone know its function or purpose?

    Code:
    <?php
    
    $sql_file=<<<SQL_FILE
    DROP TABLE IF EXISTS `table_name`;*
    CREATE TABLE IF NOT EXISTS `table_name` (
      `id` int(11) NOT NULL auto_increment,
      `name` varchar(250) default NULL,
      `address` varchar(250) default NULL,
      PRIMARY KEY  (`id`)
    );*
    SQL_FILE;
    
    ?>
  • tarek01
    New Member
    • Feb 2010
    • 14

    #2
    I finally figured out what the purpose of the * symbol was for when I stumbled upon this in the script:
    Code:
    $sql_statements = split('\;\*', $sql_file);
    for ($i = 0; $i < count($sql_statements) - 1; $i++) {
    	if (!mysql_query($sql_statements[$i], $connection)) {
    		$msg="Failed to submit the query: ".$sql_statements[$i];
    		return false;
    	}
    }
    The coder used the split function to break up $sql_file into an array of individual SQL statements wherever a ;* appears. A for loop is then used to execute each statement individually and, in the event of an error, returns which key of the array caused it.

    Sorry if I confused anyone!

    PLEASE NOTE: The split function is deprecated!

    Comment

    Working...