BUG 15089 "Pmtables: Problema al importar la data..." SOLVED
- Pmtables: Problema al importar la data de tipo Autoincrementable - Problema resuelto, el problema que se tenia era por los archivos que crea propel especificamente los archivos Peer, al momento de hacer la insercióe los campos se eliminaba la columna donde se tenia los Primary Key ocasionando que se cree nuevamente. Se valida la importacion de los pmTables cuando son de tipo Autoincrementable logrando a que cuando se importe un pmTable mantenga los íices que se tenia al momento de exportarlos.
This commit is contained in:
@@ -850,11 +850,14 @@ if (Propel::isInit()) {
|
||||
foreach ($table->getColumns() as $col) {
|
||||
$cfc = $col->getPhpName();
|
||||
if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none") {
|
||||
$comment = ($col->isPrimaryKey() && $col->isAutoIncrement()) ? "//" : "";
|
||||
|
||||
$script .= "
|
||||
\$criteria->remove(".$this->getColumnConstant($col)."); // remove pkey col since this table uses auto-increment
|
||||
";
|
||||
" . $comment . "\$criteria->remove(".$this->getColumnConstant($col)."); // remove pkey col since this table uses auto-increment
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
$script .= "
|
||||
|
||||
// Set the correct dbName
|
||||
|
||||
@@ -769,8 +769,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
$sType = fread( $fp, $fsData );
|
||||
|
||||
// first create the tables structures
|
||||
$tableNameAux = "";
|
||||
$arrayTableField = array();
|
||||
|
||||
while (! feof( $fp )) {
|
||||
switch ($sType) {
|
||||
@@ -788,8 +786,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
$tableExists = $additionalTable->loadByName( $contentSchema['ADD_TAB_NAME'] );
|
||||
$tableNameMap[$contentSchema['ADD_TAB_NAME']] = $contentSchema['ADD_TAB_NAME'];
|
||||
|
||||
$tableNameAux = $additionalTable->getPHPName($contentSchema["ADD_TAB_NAME"]);
|
||||
|
||||
if ($overWrite) {
|
||||
if ($tableExists !== false) {
|
||||
$additionalTable->deleteAll( $tableExists['ADD_TAB_UID'] );
|
||||
@@ -820,8 +816,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
$columns[] = $column;
|
||||
}
|
||||
|
||||
$arrayTableField = $columns;
|
||||
|
||||
$tableData = new stdClass();
|
||||
$tableData->REP_TAB_UID = $contentSchema['ADD_TAB_UID'];
|
||||
$tableData->REP_TAB_NAME = $contentSchema['ADD_TAB_NAME'];
|
||||
@@ -885,44 +879,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
$fsData = intval( fread( $fp, 9 ) );
|
||||
$sType = fread( $fp, $fsData );
|
||||
|
||||
//Verify Primary Key Auto-Increment
|
||||
$flagPkAutoIncrement = 0;
|
||||
|
||||
foreach ($arrayTableField as $value) {
|
||||
if ($value["field_key"] . "" == "1" && $value["field_autoincrement"] . "" == "1") {
|
||||
$flagPkAutoIncrement = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($flagPkAutoIncrement == 1) {
|
||||
$fileBasePeer = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . "om". PATH_SEP . "Base" . $tableNameAux . "Peer.php";
|
||||
|
||||
if (file_exists($fileBasePeer)) {
|
||||
$fh = fopen($fileBasePeer, "r");
|
||||
|
||||
if ($fh) {
|
||||
$content = "";
|
||||
|
||||
while (!feof($fh)) {
|
||||
$line = fgets($fh, 4096); //Read a line.
|
||||
|
||||
if (preg_match("/^.*criteria.*auto\-increment.*$/", $line)) {
|
||||
$line = "//" . $line;
|
||||
}
|
||||
|
||||
$content = $content . $line;
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
|
||||
unlink($fileBasePeer);
|
||||
|
||||
file_put_contents($fileBasePeer, $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// data processing
|
||||
while (! feof( $fp )) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user