array CDatabase::ParseSqlBatch( string sql )
The method ParseSqlBatch parses the string containing a bundle of queries and creates an array of queries.
Parameter | Description |
---|---|
sql | String containing a bundle of queries. Queries are separated with ";" for the MySQL version or "/" for the Oracle version. |
Array of queries.
<? function RunSqlBatch($filepath) { $arErr = Array(); // open a file with queries $f = @fopen($filepath, "rb"); if($f) { $contents = fread($f, filesize($filepath)); fclose($f); // split into separate queries $arSql = $this->ParseSqlBatch($contents); for($i=0; $i<count($arSql); $i++) { $strSql = str_replace("\r\n", "\n", $arSql[$i]); if(!$this->Query($strSql, true)) $arErr[] = $this->db_Error; } } if(count($arErr)>0) return $arErr; return false; } ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |