Documentation

RunSqlBatch

mixed
CDatabase::RunSqlBatch(
 string path,
 bool Incremental = False
)

The method executes a query packet from the path file. Returns "false", if all queries are successful. Otherwise, the method returns array of error descriptions for specific queries that resulted in failure. Non-static method.

Parameters

ParameterDescription Available from version
path File that contains packet of queries. The MySQL queries are separated with ";". The Oracle queries are separated with "/".
Incremental Optional. False by default.

See Also

Example of function call

<?
$arrErrors = $DB->RunSqlBatch($_SERVER["DOCUMENT_ROOT"].
"/bitrix/modules/form/install/db/".strtolower($DB->type)."/install.sql");
?>

Sample file with MySQL queries

cre ate   table if not exists b_stat_adv_searcher (
   ID int(11) not null auto_increment,  
   ADV_ID int(11) not null,  
   SEARCHER_ID int(11) not null,  
   primary key (ID));
ins ert  in to b_stat_adv (ID, REFERER1, REFERER2) values (1, 'aport', '') ;
ins ert  in to b_stat_adv_searcher (ID, ADV_ID, SEARCHER_ID) values (1, 2, 4) ;

Sample file with Oracle queries

CRE ATE   TABLE B_STAT_ADDITIONAL 
(
    ID         NUMBER(18)    NOT NULL,
    C_TYPE     VARCHAR2(255) NOT NULL,
    NAME       NUMBER(18)    NULL,
    SESSIONS   NUMBER(18)    DEFAULT 0 NOT NULL,
    HITS       NUMBER(18)    DEFAULT 0 NOT NULL,
    NEW_GUESTS NUMBER(18)    DEFAULT 0 NOT NULL,
    C_EVENTS   NUMBER(18)    DEFAULT 0 NOT NULL,
    PRIMARY KEY (ID)
)
/
CREATE SEQUENCE SQ_B_STAT_ADDITIONAL 
	START WITH 44 
	INCREMENT BY 1 
	NOMINVALUE 
	NOMAXVALUE 
	NOCYCLE 
	NOCACHE 
	NOORDER
/
INS ERT IN TO B_STAT_ADV (ID, REFERER1, REFERER2) VALUES (1, 'aport', '')
/
DROP SEQUENCE SQ_B_STAT_ADV
/
CREATE SEQUENCE SQ_B_STAT_ADV 
	START WITH 8 
	INCREMENT BY 1 
	NOMINVALUE 
	NOMAXVALUE 
	NOCYCLE 
	NOCACHE 
	NOORDER
/
INS ERT IN TO B_STAT_ADV_SEARCHER (ID, ADV_ID, SEARCHER_ID) VALUES (1, 2, 4)
/


© «Bitrix24», 2001-2024
Up