Created
December 14, 2011 05:47
-
-
Save predominant/1475439 to your computer and use it in GitHub Desktop.
Automatic table creation for missing tables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppModel extends Model { | |
/** | |
* Overridden setSource allows creation of table in the event a MissingTableException is raised. | |
* | |
* @param string $tablename Table name | |
* @return void | |
*/ | |
public function setSource($tablename) { | |
try { | |
parent::setSource($tablename); | |
} catch (MissingTableException $e) { | |
$this->query($this->_createStatement); | |
parent::setSource($tablename); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment