I'm currently developing a modular site with silex, propel and twig. It is my intention to create an installer project on top of it so I can easily create new projects based on my "core" project.
My database has some many-to-many table which require the isCrossRef attribute in my schema.xml. When reverse engineering my MySql database Propel can't determine which tables are crossRef. I get that, but now I was wondering if I could alter the schema.xml generation.
Lets says If I add a comment to the tables that need this isCrossRef attribute, then where in the Propel source code would I be able to read out this comment and add the required IsCrossRef to the generated schema.xml ?
After reading some of the source code I found the answer myself :
If u want to accomplish this u will need the modify the file : MysqlSchemaParser.php, located at : propel1/generator/lib/reverse/mysql (when installed with composer)
Alter the recordset at line 99 to :
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$name = $row[0];
$type = $row[1];
if ($name == $this->getMigrationTable() || $type != "BASE TABLE") {
continue;
}
/*
Edit : Find out if table isCrossRef
*/
$commentStmt = $this->dbh->query("show table status like '".$name."'");
$commentRow = $commentStmt->fetch(PDO::FETCH_OBJ);
$isCrossRef = (strtolower($commentRow->Comment) == 'iscrossref');
/*
End of edit
*/
if ($task) {
$task->log(" Adding table '" . $name . "'", Project::MSG_VERBOSE);
}
$table = new Table($name);
$table->setIdMethod($database->getDefaultIdMethod());
$table->setIsCrossRef($isCrossRef); /*EDIT : set is crossref to true*/
$database->addTable($table);
$tables[] = $table;
}