[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php foreach ($table->getForeignKeys() as $fk) { ?> 2 IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='<?php echo $fk->getName() ?>') 3 ALTER TABLE <?php echo $table->getName() ?> DROP CONSTRAINT <?php echo $fk->getName()?>; 4 <?php } ?> 5 <?php 6 // this file is being included within another foreach() loop. 7 // we want to create a global var that is aware of what instance 8 // this is within that loop; 9 global $__mssql_drop_count; 10 11 if (!isset($__mssql_drop_count)) { 12 $__mssql_drop_count = 0; 13 } 14 15 $__mssql_drop_count++; 16 ?> 17 IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '<?php echo $table->getName() ?>') 18 BEGIN 19 DECLARE @reftable_<?php echo $__mssql_drop_count ?> nvarchar(60), @constraintname_<?php echo $__mssql_drop_count ?> nvarchar(60) 20 DECLARE refcursor CURSOR FOR 21 select reftables.name tablename, cons.name constraintname 22 from sysobjects tables, 23 sysobjects reftables, 24 sysobjects cons, 25 sysreferences ref 26 where tables.id = ref.rkeyid 27 and cons.id = ref.constid 28 and reftables.id = ref.fkeyid 29 and tables.name = '<?php echo $table->getName() ?>' 30 OPEN refcursor 31 FETCH NEXT from refcursor into @reftable_<?php echo $__mssql_drop_count ?>, @constraintname_<?php echo $__mssql_drop_count ?> 32 while @@FETCH_STATUS = 0 33 BEGIN 34 exec ('alter table '+@reftable_<?php echo $__mssql_drop_count ?>+' drop constraint '+@constraintname_<?php echo $__mssql_drop_count ?>) 35 FETCH NEXT from refcursor into @reftable_<?php echo $__mssql_drop_count ?>, @constraintname_<?php echo $__mssql_drop_count ?> 36 END 37 CLOSE refcursor 38 DEALLOCATE refcursor 39 DROP TABLE <?php echo $table->getName() ?> 40 41 END 42
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |