initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?php
foreach ($table->getColumns() as $col) {
$type = $col->getDomain()->getSqlType();
if ($type == "INT" || $type == "TEXT") {
$size = "";
} else {
$size = $col->printSize();
}
$default = $col->getDefaultSetting();
$entry = $col->getName() . ' ' . $type . ' ' . $size . ' ' . $default . ' ' . $col->getNotNullString() . ' ' . $col->getAutoIncrementString();
// collapse spaces
$entry = preg_replace('/[\s]+/', ' ', $entry);
// ' ,' -> ','
$entry = preg_replace('/[\s]*,[\s]*/', ',', $entry);
?>
<?php echo $entry ?>,
<?php } ?>

View File

@ -0,0 +1,42 @@
<?php foreach ($table->getForeignKeys() as $fk) { ?>
IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='<?php echo $fk->getName() ?>')
ALTER TABLE <?php echo $table->getName() ?> DROP CONSTRAINT <?php echo $fk->getName()?>;
<?php } ?>
<?php
// this file is being included within another foreach() loop.
// we want to create a global var that is aware of what instance
// this is within that loop;
global $__mssql_drop_count;
if (!isset($__mssql_drop_count)) {
$__mssql_drop_count = 0;
}
$__mssql_drop_count++;
?>
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '<?php echo $table->getName() ?>')
BEGIN
DECLARE @reftable_<?php echo $__mssql_drop_count ?> nvarchar(60), @constraintname_<?php echo $__mssql_drop_count ?> nvarchar(60)
DECLARE refcursor CURSOR FOR
select reftables.name tablename, cons.name constraintname
from sysobjects tables,
sysobjects reftables,
sysobjects cons,
sysreferences ref
where tables.id = ref.rkeyid
and cons.id = ref.constid
and reftables.id = ref.fkeyid
and tables.name = '<?php echo $table->getName() ?>'
OPEN refcursor
FETCH NEXT from refcursor into @reftable_<?php echo $__mssql_drop_count ?>, @constraintname_<?php echo $__mssql_drop_count ?>
while @@FETCH_STATUS = 0
BEGIN
exec ('alter table '+@reftable_<?php echo $__mssql_drop_count ?>+' drop constraint '+@constraintname_<?php echo $__mssql_drop_count ?>)
FETCH NEXT from refcursor into @reftable_<?php echo $__mssql_drop_count ?>, @constraintname_<?php echo $__mssql_drop_count ?>
END
CLOSE refcursor
DEALLOCATE refcursor
DROP TABLE <?php echo $table->getName() ?>
END

View File

@ -0,0 +1,17 @@
<?php foreach ($tablefk->getForeignKeys() as $fk) { ?>
BEGIN
ALTER TABLE <?php echo $tablefk->getName() ?>
ADD CONSTRAINT <?php echo $fk->getName() ?> FOREIGN KEY (<?php echo $fk->getLocalColumnNames() ?>)
REFERENCES <?php echo $fk->getForeignTableName() ?> (<?php echo $fk->getForeignColumnNames() ?>)
<?php if ($fk->hasOnUpdate()) { ?>
ON UPDATE <?php echo $fk->getOnUpdate() ?>
<?php } ?>
<?php if ($fk->hasOnDelete()) { ?>
ON DELETE <?php echo $fk->getOnDelete() ?>
<?php } ?>
END
;
<?php } ?>

View File

@ -0,0 +1,4 @@
<?php foreach ($table->getIndices() as $index) { ?>
CREATE <?php if($index->isUnique()) { ?>UNIQUE<?php } ?> INDEX <?php echo $index->getName() ?> ON <?php echo $table->getName() ?> (<?php echo $index->getColumnList()?>);
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php if ($table->hasPrimaryKey()) { ?>
CONSTRAINT <?php echo $table->getName() ?>_PK PRIMARY KEY(<?php echo $table->printPrimaryKey() ?>),
<?php } ?>

View File

@ -0,0 +1,38 @@
/* ---------------------------------------------------------------------- */
/* <?php echo $table->getName() ?> */
/* ---------------------------------------------------------------------- */
<?php echo $generator->parse("$basepath/drop.tpl"); ?>
CREATE TABLE <?php echo $table->getName()?>
(
<?php
$cols = $generator->parse("$basepath/columns.tpl");
$pk = $generator->parse("$basepath/primarykey.tpl");
$unique = $generator->parse("$basepath/unique.tpl");
if (empty($pk) && empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $cols);
} else {
echo $cols;
}
if (!empty($pk) && empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $pk);
} else {
echo $pk;
}
if (!empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $unique);
}
?>
);
<?php
$index = $generator->parse("$basepath/index.tpl");
if (!empty($index)) {
echo $index;
}
?>

View File

@ -0,0 +1,11 @@
/* ---------------------------------------------------------------------- */
/* <?php echo $tablefk->getName() ?> */
/* ---------------------------------------------------------------------- */
<?php
$fk = $generator->parse("$basepath/foreignkey.tpl");
if (!empty($fk)) {
echo $fk;
}
?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getUnices() as $unique) { ?>
UNIQUE (<?php echo $unique->getColumnList() ?>),
<?php } ?>

View File

@ -0,0 +1,28 @@
<?php
$firstIteration = true;
foreach ($table->getColumns() as $col) {
if(!$firstIteration): ?>,
<?php endif; $firstIteration = false;
//$entry = $col->getSqlString();
//using the following code instead of the above line
//for escaping column names:
$entry = "";
$entry .= "`" . $col->getName() . "` ";
$entry .= $col->getDomain()->getSqlType();
if ($col->getPlatform()->hasSize($col->getDomain()->getSqlType())) {
$entry .= $col->getDomain()->printSize();
}
$entry .= " ";
$entry .= $col->getDefaultSetting() . " ";
$entry .= $col->getNotNullString() . " ";
$entry .= $col->getAutoIncrementString();
// collapse spaces
$entry = preg_replace('/[\s]+/', ' ', $entry);
// ' ,' -> ','
$entry = preg_replace('/[\s]*,[\s]*/', ',', $entry);
?>
<?php echo $entry ?><?php if ($col->getDescription()) { ?> COMMENT '<?php echo $platform->escapeText($col->getDescription()) ?>'<?php } ?>
<?php }

View File

@ -0,0 +1,5 @@
# This restores the fkey checks, after having unset them
# in database-start.tpl
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -0,0 +1,4 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS <?php echo "`" . $table->getName() . "`" ?>;

View File

@ -0,0 +1,86 @@
<?php
$_indices = array();
$_previousColumns = array();
// we're building an array of indices here which is smart about multi-column indices.
// for example, if we have to indices foo(ColA) and bar(ColB, ColC), we have actually three indices already defined:
// ColA, ColB+ColC, and ColB (but not ColC!). This is because of the way SQL multi-column indices work.
// we will later match found, defined foreign key and referenced column definitions against this array to know whether we should create a new index for mysql or not
foreach($table->getPrimaryKey() as $_primaryKeyColumn)
{
// do the above for primary keys
$_previousColumns[] = "`" . $_primaryKeyColumn->getName() . "`";
$_indices[] = implode(',', $_previousColumns);
}
$_tableIndices = array_merge($table->getIndices(), $table->getUnices());
foreach($_tableIndices as $_index)
{
// same procedure, this time for unices and indices
$_previousColumns = array();
$_indexColumns = $_index->getColumns();
foreach($_indexColumns as $_indexColumn)
{
$_previousColumns[] = "`" . $_indexColumn . "`";
$_indices[] = implode(',', $_previousColumns);
}
}
$_tables = $table->getDatabase()->getTables();
$counter = 0;
// we're determining which tables have foreign keys that point to this table, since MySQL needs an index on any column that is referenced by another table (yep, MySQL _is_ a PITA)
foreach($_tables as $_table)
{
foreach($_table->getForeignKeys() as $_foreignKey)
{
if($_foreignKey->getForeignTableName() == $table->getName())
{
$_foreignColumns = array();
foreach($_foreignKey->getForeignColumns() as $_foreignColumn)
{
$_foreignColumns[] = "`" . $_foreignColumn . "`";
}
if(!in_array(implode(',', $_foreignColumns), $_indices))
{
// no matching index defined in the schema, so we have to create one
$counter++;
if($counter > 1): ?>,<?php endif;
?>
INDEX `I_referenced_<?php echo $_foreignKey->getName(); ?>_<?php echo $counter; ?>` (<?php echo implode(',',$_foreignColumns); ?>)<?php
}
}
}
}
$hasReferencedColumns = $counter > 0;
$counter = 0;
foreach ($table->getForeignKeys() as $fk) {
if($counter > 0 || $hasReferencedColumns): ?>,<?php endif;
$counter++;
$fnames = array();
foreach ($fk->getForeignColumns() as $column) {
$fnames[] = "`" . $column . "`";
}
$lnames = array();
foreach ($fk->getLocalColumns() as $column) {
$lnames[] = "`" . $column . "`";
}
$constraintName = "`" . $fk->getName() . "`";
$indexName = "`" . substr_replace($fk->getName(), 'FI_', strrpos($fk->getName(), 'FK_'), 3) . "`";
if(!in_array(implode(',', $lnames), $_indices))
{
// no matching index defined in the schema, so we have to create one. MySQL needs indices on any columns that serve as foreign keys. these are not auto-created prior to 4.1.2
?>
INDEX <?php echo $indexName; ?> (<?php echo implode(',', $lnames); ?>),<?php
}
?>
CONSTRAINT <?php echo $constraintName ?>
FOREIGN KEY (<?php echo implode(',', $lnames); ?>)
REFERENCES <?php echo "`" . $fk->getForeignTableName() . "`" ?> (<?php echo implode(',', $fnames); ?>)
<?php if ($fk->hasOnUpdate()) { ?>
ON UPDATE <?php echo $fk->getOnUpdate(); ?>
<?php } if ($fk->hasOnDelete()) { ?>
ON DELETE <?php echo $fk->getOnDelete();
}
}

View File

@ -0,0 +1,10 @@
<?php $firstIteration = true; foreach ($table->getIndices() as $index ) {
$vendor = $index->getVendorSpecificInfo();
if(!$firstIteration): ?>,<?php endif; $firstIteration = false; ?>
<?php echo ($vendor && $vendor['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : '' ?>KEY <?php echo "`" . $index->getName() . "`" ?> (<?php
$values = array();
foreach ($index->getColumns() as $column) {
$values[] = "`" . $column . "`";
}
echo implode(',', $values);
?>)<?php }

View File

@ -0,0 +1,7 @@
<?php if ($table->hasPrimaryKey()) {
$values = array();
foreach ($table->getPrimaryKey() as $column) {
$values[] = "`" . $column->getName() . "`";
}
?>
PRIMARY KEY(<?php echo implode(',', $values) ?>)<?php }

View File

@ -0,0 +1,45 @@
# -----------------------------------------------------------------------
# <?php echo $table->getName() ?>
# -----------------------------------------------------------------------
<?php echo $generator->parse("$basepath/drop.tpl") ?>
CREATE TABLE <?php echo "`" . $table->getName() . "`" ?>
(
<?php
$cols = $generator->parse("$basepath/columns.tpl");
$pk = $generator->parse("$basepath/primarykey.tpl");
$fk = $generator->parse("$basepath/foreignkey.tpl");
$unique = $generator->parse("$basepath/unique.tpl");
$index = $generator->parse("$basepath/index.tpl");
$output = array();
if(!empty($cols)) {
$output[] = $cols;
}
if(!empty($pk)) {
$output[] = $pk;
}
if(!empty($unique)) {
$output[] = $unique;
}
if(!empty($index)) {
$output[] = $index;
}
if(!empty($fk)) {
$output[] = $fk;
}
echo implode(", ", $output);
?>
)<?php if (!isset($mysqlTableType)) {
$vendorSpecific = $table->getVendorSpecificInfo();
if(isset($vendorSpecific['Type']))
$mysqlTableType = $vendorSpecific['Type'];
else
$mysqlTableType = 'MyISAM';
}
?>
Type=<?php echo $mysqlTableType ?>
<?php if($table->getDescription()) { ?> COMMENT='<?php echo $platform->escapeText($table->getDescription()) ?>'<?php } ?>;

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,12 @@
<?php
$firstIteration = true;
foreach ($table->getUnices() as $index ) {
if(!$firstIteration): ?>, <?php endif; $firstIteration = false;
?>
UNIQUE KEY <?php echo "`" . $index->getName() . "`" ?> (<?php
$values = array();
foreach ($index->getColumns() as $column) {
$values[] = "`" . $column . "`";
}
echo implode(',', $values);
?>)<?php }

View File

@ -0,0 +1,19 @@
<?php
foreach ($table->getColumns() as $col) {
/*
$type = $col->getSqlType();
$size = $col->printSize();
$default = $col->getDefaultSetting();
$entry = $col->getName() . " $type $size $default ".$col->getNotNullString();
*/
$entry = $col->getSqlString();
// collapse spaces
$entry = preg_replace('/[\s]+/', ' ', $entry);
// ' ,' -> ','
$entry = preg_replace('/[\s]*,[\s]*/', ',', $entry);
?>
<?php echo $entry ?>,<?php } ?>

View File

@ -0,0 +1,4 @@
DROP TABLE <?php echo $table->getName() ?> CASCADE CONSTRAINTS;
<?php if ($table->getIdMethod() == "native") { ?>
DROP SEQUENCE <?php echo $table->getSequenceName() ?>;
<?php } ?>

View File

@ -0,0 +1,16 @@
<?php foreach ($tablefk->getForeignKeys() as $fk) { ?>
ALTER TABLE <?php echo $tablefk->getName()?>
ADD CONSTRAINT <?php echo $fk->getName() ?> FOREIGN KEY (<?php echo $fk->getLocalColumnNames()?>)
REFERENCES <?php echo $fk->getForeignTableName()?> (<?php echo $fk->getForeignColumnNames()?>)<?php
if ($fk->hasOnDelete()) {?>
ON DELETE <?php echo $fk->getOnDelete();
}?>;
<?php } ?>
<?php
/*
-- TODO
ON UPDATE $fk.OnUpdate
*/
?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getIndices() as $index) { ?>
CREATE<?php if ($index->isUnique()) { ?> UNIQUE<?php } ?> INDEX <?php echo $index->getName(); ?> ON <?php echo $table->getName(); ?> (<?php echo $index->getColumnList(); ?>);
<?php } ?>

View File

@ -0,0 +1,19 @@
<?php
$tableName = $table->getName();
$length = strlen($tableName);
if ($length > 27) {
$length = 27;
}
?>
<?php if ( is_array($table->getPrimaryKey()) && count($table->getPrimaryKey()) ) { ?>
ALTER TABLE <?php echo $table->getName() ?>
ADD CONSTRAINT <?php echo substr($tableName,0,$length)?>_PK
PRIMARY KEY (<?php
$delim = "";
foreach ($table->getPrimaryKey() as $col) {
echo $delim . $col->getName();
$delim = ",";
}
?>);
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php if ($table->getIdMethod() == "native") { ?>
CREATE SEQUENCE <?php echo $table->getSequenceName()?> INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER;
<?php } ?>

View File

@ -0,0 +1,26 @@
/* -----------------------------------------------------------------------
<?php echo $table->getName() ?>
----------------------------------------------------------------------- */
<?php echo $generator->parse("$basepath/drop.tpl") ?>
CREATE TABLE <?php echo $table->getName() ?>
(<?php
$cols = $generator->parse("$basepath/columns.tpl");
$unique = $generator->parse("$basepath/unique.tpl");
if (empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $cols);
} else {
echo $cols;
}
if (!empty($unique)) {
echo "\n" . preg_replace('/[ ,]+[\s]*$/', '', $unique);
}
?>
);
<?php echo $generator->parse("$basepath/primarykey.tpl")?>
<?php echo $generator->parse("$basepath/index.tpl")?>
<?php echo $generator->parse("$basepath/sequence.tpl")?>

View File

@ -0,0 +1,5 @@
<?php
$entry = $generator->parse("$basepath/foreignkey.tpl");
echo $entry;
?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getUnices() as $unique) { ?>
CONSTRAINT <?php echo $unique->getName(); ?> UNIQUE (<?php echo $unique->getColumnList(); ?>),
<?php } ?>

View File

@ -0,0 +1,13 @@
<?php
foreach ($table->getColumns() as $col) {
$entry = $col->getSqlString();
// collapse spaces
$entry = preg_replace('/[\s]+/', ' ', $entry);
// ' ,' -> ','
$entry = preg_replace('/[\s]*,[\s]*/', ',', $entry);
?>
<?php echo $entry ?>,
<?php } ?>

View File

@ -0,0 +1,4 @@
DROP TABLE <?php echo $table->getName() ?> CASCADE;
<?php if ($table->getIdMethod() == "native") { ?>
DROP SEQUENCE <?php echo $table->getSequenceName() ?>;
<?php } ?>

View File

@ -0,0 +1,20 @@
<?php
//
// The following will only work for non-circular references
// if you have a dependancy chain, you will need to use
// ADD CONSTRAINT syntax (with INITIALLY DEFERRED)
// which is sticky and version dependant
//
foreach ($tablefk->getForeignKeys() as $fk) { ?>
ALTER TABLE <?php echo $tablefk->getName() ?>
ADD CONSTRAINT <?php echo $fk->getName() ?> FOREIGN KEY (<?php echo $fk->getLocalColumnNames() ?>)
REFERENCES <?php echo $fk->getForeignTableName() ?> (<?php echo $fk->getForeignColumnNames() ?>)
<?php if ($fk->hasOnUpdate()) { ?>
ON UPDATE <?php echo $fk->getOnUpdate() ?>
<?php } ?>
<?php if ($fk->hasOnDelete()) { ?>
ON DELETE <?php echo $fk->getOnDelete() ?>
<?php } ?>
;
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getIndices() as $index) { ?>
CREATE <?php if($index->getIsUnique()) { ?>UNIQUE<?php } ?> INDEX <?php echo $index->getName() ?> ON <?php echo $table->getName() ?> (<?php echo $index->getColumnList()?>);
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php if ($table->hasPrimaryKey()) { ?>
PRIMARY KEY (<?php echo $table->printPrimaryKey() ?>),
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php if ($table->getIdMethod() == "native") { ?>
CREATE SEQUENCE <?php echo $table->getSequenceName() ?>;
<?php } ?>

View File

@ -0,0 +1,55 @@
-----------------------------------------------------------------------------
-- <?php echo $table->getName() ?>
-----------------------------------------------------------------------------
<?php
echo $generator->parse("$basepath/drop.tpl");
$sequence = $generator->parse("$basepath/sequence.tpl");
if (!empty($sequence)) {
echo $sequence;
}
?>
CREATE TABLE <?php echo $table->getName() ?>
(
<?php
$cols = $generator->parse("$basepath/columns.tpl");
$pk = trim($generator->parse("$basepath/primarykey.tpl"));
$unique = $generator->parse("$basepath/unique.tpl");
$index = trim($generator->parse("$basepath/index.tpl"));
if ( empty($pk) && empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $cols);
} else {
echo $cols;
}
if (empty($unique) && !empty($pk)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $pk);
} else {
echo $pk;
}
if (!empty($unique)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $unique);
}
?>
);
<?php
if(!empty($index)) {
echo preg_replace('/[ ,]+[\s]*$/', '', $index);
}
?>
COMMENT ON TABLE <?php echo $table->getName() ?> IS '<?php echo $platform->escapeText($table->getDescription()) ?>';
<?php
foreach ($table->getColumns() as $col) {
if( $col->getDescription() != '' ) {
?>
COMMENT ON COLUMN <?php echo $table->getName() ?>.<?php echo $col->getName() ?> IS '<?php echo $platform->escapeText($col->getDescription()) ?>';
<?php
}
}
?>

View File

@ -0,0 +1,14 @@
----------------------------------------------------------------------
-- <?php echo $tablefk->getName() ?>
----------------------------------------------------------------------
<?php
// for pgsql table = tablefk, because
// foreignkey.tpl can be loaded by table.tpl also
//$generator->put("table", $tablefk);
$fk = $generator->parse("$basepath/foreignkey.tpl");
if ($fk != "") {
echo $fk;
}
?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getUnices() as $unique ) { ?>
CONSTRAINT <?php echo $unique->getName() ?> UNIQUE (<?php echo $unique->getColumnList() ?>),
<?php } ?>

View File

@ -0,0 +1,13 @@
<?php
foreach ($table->getColumns() as $col) {
$entry = $col->getSqlString();
// collapse spaces
$entry = preg_replace('/[\s]+/', ' ', $entry);
// ' ,' -> ','
$entry = preg_replace('/[\s]*,[\s]*/', ',', $entry);
?>
<?php echo $entry ?>,
<?php } ?>

View File

@ -0,0 +1 @@
drop table <?php echo $table->getName() ?>;

View File

@ -0,0 +1,4 @@
<?php foreach ($table->getForeignKeys() as $fk) { ?>
-- SQLite does not support foreign keys; this is just for reference
-- FOREIGN KEY (<?php echo $fk->getLocalColumnNames()?>) REFERENCES <?php echo $fk->getForeignTableName() ?> (<?php echo $fk->getForeignColumnNames() ?>),
<?php } ?>

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getIndices() as $index ) { ?>
CREATE INDEX <?php echo $index->getName()?> ON <?php echo $table->getName() ?> (<?php echo $index->getColumnList() ?>);
<?php } ?>

View File

@ -0,0 +1,33 @@
-- -----------------------------------------------------------------------
-- <?php echo $table->getName() ?>
-- -----------------------------------------------------------------------
<?php echo $generator->parse("$basepath/drop.tpl") ?>
CREATE TABLE <?php echo $table->getName() ?>
(
<?php
$cols = $generator->parse("$basepath/columns.tpl");
$fk = $generator->parse("$basepath/foreignkey.tpl");
$unique = $generator->parse("$basepath/unique.tpl");
$index = $generator->parse("$basepath/index.tpl");
if (empty($unique)) {
echo preg_replace('/[,]+\s*$/', '', $cols);
} else {
echo $cols;
echo preg_replace('/[,]+\s*$/', '', $unique);
}
?>
);
<?php
if (!empty($index)) {
echo $index;
}
if (!empty($fk)) {
echo $fk;
}
?>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
<?php foreach ($table->getUnices() as $unique) { ?>
UNIQUE (<?php echo $unique->getColumnList() ?>),
<?php } ?>

View File

@ -0,0 +1,13 @@
<?php
// build db names array
$databaseNames = array();
foreach($dataModels as $dm) {
foreach($dm->getDatabases() as $db) {
$databaseNames[] = $db->getName();
}
}
$databaseNames = array_unique($databaseNames);
$generator->put("databaseNames", $databaseNames);
$generator->display("sql/db-init/$targetDatabase/createdb.tpl");
?>

View File

@ -0,0 +1,6 @@
#!/bin/sh
#foreach ($databaseModel in $appData.Databases)
dropdb $databaseModel.Name
createdb $databaseModel.Name
#end

View File

@ -0,0 +1 @@
ECHO Not implemented

View File

@ -0,0 +1,4 @@
<?php foreach( $databaseNames as $databaseName) { ?>
drop database if exists <?php echo $databaseName ?>;
create database <?php echo $databaseName ?>;
<?php } /* foreach */ ?>

View File

@ -0,0 +1,4 @@
-- foreach ($databaseName in $databaseNames)
-- drop database $databaseName;
-- create database $databaseName;
-- end

View File

@ -0,0 +1,4 @@
<?php foreach( $databaseNames as $databaseName) { ?>
drop database <?php echo $databaseName ?>;
create database <?php echo $databaseName ?>;
<?php } /* foreach */ ?>

View File

@ -0,0 +1,14 @@
INSERT INTO <?php echo $row->getTable()->getName() ?> (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
print $col->getColumn()->getName();
$comma = ',';
}?>) VALUES (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
$generator->put("column", $col);
$generator->display("sql/load/mssql/val.tpl");
$comma=',';
}?>);

View File

@ -0,0 +1,9 @@
<?php
if (in_array($column->getColumn()->getPropelType(), array('VARCHAR', 'LONGVARCHAR', 'DATE','CHAR'))) {
echo "'" . str_replace("'", "''", $column->getValue()). "'";
} else {
echo $column->getValue();
}
?>

View File

@ -0,0 +1,14 @@
INSERT INTO <?php echo "`" . $row->getTable()->getName() . "`" ?> (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
print "`" . $col->getColumn()->getName() . "`";
$comma = ',';
}?>) VALUES (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
$generator->put("column", $col);
$generator->display("sql/load/mysql/val.tpl");
$comma=',';
}?>);

View File

@ -0,0 +1,7 @@
<?php
if (in_array($column->getColumn()->getPropelType(), array('VARCHAR', 'LONGVARCHAR', 'DATE', 'DATETIME','CHAR'))) {
print "'" . mysql_escape_string($column->getValue()) . "'";
} else {
print $column->getValue();
}
?>

View File

@ -0,0 +1,14 @@
INSERT INTO <?php echo $row->getTable()->getName() ?> (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
print $col->getColumn()->getName();
$comma = ',';
}?>) VALUES (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
$generator->put("column", $col);
$generator->display("sql/load/oracle/val.tpl");
$comma=',';
}?>);

View File

@ -0,0 +1,9 @@
<?php
if (in_array($column->getColumn()->getPropelType(), array('VARCHAR', 'LONGVARCHAR', 'DATE','CHAR'))) {
echo "'" . $column->getValue() . "'";
} else {
echo $column->getValue();
}
?>

View File

@ -0,0 +1,14 @@
INSERT INTO <?php echo $row->getTable()->getName() ?> (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
print $col->getColumn()->getName();
$comma = ',';
}?>) VALUES (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
$generator->put("column", $col);
$generator->display("sql/load/pgsql/val.tpl");
$comma=',';
}?>);

View File

@ -0,0 +1,11 @@
<?php
if (in_array($column->getColumn()->getPropelType(), array('VARCHAR', 'LONGVARCHAR', 'DATE','CHAR', 'TIMESTAMP'))) {
echo "'" . pg_escape_string($column->getValue()) . "'";
} elseif ($column->getColumn()->getPropelType() == 'BOOLEAN') {
echo ($column->getValue() == 1 || $column->getValue() == 't' ? "'t'" : "'f'");
} else {
echo $column->getValue();
}
?>

View File

@ -0,0 +1,14 @@
INSERT INTO <?php echo $row->getTable()->getName() ?> (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
print $col->getColumn()->getName();
$comma = ',';
}?>) VALUES (<?php
$comma="";
foreach($row->getColumnValues() as $col) {
print $comma;
$generator->put("column", $col);
$generator->display("sql/load/sqlite/val.tpl");
$comma=',';
}?>);

View File

@ -0,0 +1,4 @@
<?php
// SQLite is typeless, so we'll treat everything like string
print "'" . sqlite_escape_string($column->getValue()) . "'";
?>