Guest User

Untitled

a guest
Jan 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1.  
  2. App::import('Model', 'CakeSchema');
  3. App::import('Model', 'ConnectionManager');
  4. include_once(APP.'plugins'.DS.'pluginname'.DS.'config'.DS.'schema'.DS.'schema.php');
  5. $db = ConnectionManager::getDataSource('default');
  6.  
  7. //Get all available tables
  8. $tables = $db->listSources();
  9.  
  10. $CakeSchema = new CakeSchema();
  11. $SubSchema = new PluginnameSchema();
  12.  
  13. foreach ($SubSchema->tables as $table => $config) {
  14. if (!in_array($table, $tables)) {
  15. $db->execute($db->createSchema($SubSchema, $table));
  16. }
  17. }
  18.  
  19. //Ignore the cache since the tables wont be inside the cache at this point
  20. @unlink(TMP . 'cache' . DS . 'models/cake_model_' . ConnectionManager::getSourceName($db). '_' . $db->config["database"] . '_list');
  21. $db->sources(true);
Add Comment
Please, Sign In to add comment