mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
adding i18n and sessions schema files. command modified slightly to : cake schema run create DbAcl, cake schema run create i18n, and cake schema run create Sessions
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6077 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ff8faa5318
commit
b6b192fda6
9 changed files with 336 additions and 48 deletions
|
@ -1,8 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
/* SVN FILE: $Id$ */
|
/* SVN FILE: $Id$ */
|
||||||
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
|
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
|
||||||
|
/**
|
||||||
|
* This is Acl Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for ACL
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create DbAcl
|
||||||
|
*
|
||||||
|
*/
|
||||||
class DbAclSchema extends CakeSchema {
|
class DbAclSchema extends CakeSchema {
|
||||||
|
|
||||||
var $name = 'DbAcl';
|
var $name = 'DbAcl';
|
||||||
|
|
58
app/config/sql/i18n.php
Normal file
58
app/config/sql/i18n.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/*i18n schema generated on: 2007-11-25 07:11:25 : 1196004805*/
|
||||||
|
/**
|
||||||
|
* This is i18n Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for i18n
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create i18n
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class i18nSchema extends CakeSchema {
|
||||||
|
|
||||||
|
var $name = 'i18n';
|
||||||
|
|
||||||
|
function before($event = array()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function after($event = array()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
var $i18n = array(
|
||||||
|
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary', 'extra' => 'auto_increment'),
|
||||||
|
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
|
||||||
|
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||||
|
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
|
||||||
|
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||||
|
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||||
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
55
app/config/sql/sessions.php
Normal file
55
app/config/sql/sessions.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/*Sessions schema generated on: 2007-11-25 07:11:54 : 1196004714*/
|
||||||
|
/**
|
||||||
|
* This is Sessions Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for Sessions
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create Sessions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SessionsSchema extends CakeSchema {
|
||||||
|
|
||||||
|
var $name = 'Sessions';
|
||||||
|
|
||||||
|
function before($event = array()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function after($event = array()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
var $cake_sessions = array(
|
||||||
|
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
|
||||||
|
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||||
|
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
|
||||||
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
|
@ -340,7 +340,7 @@ class AclShell extends Shell {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function initdb() {
|
function initdb() {
|
||||||
$this->err('This command is deprecated. Please use, cake schema run create -name DbAcl');
|
$this->err('This command is deprecated. Please use, cake schema run create DbAcl');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Show help screen.
|
* Show help screen.
|
||||||
|
@ -394,7 +394,7 @@ class AclShell extends Shell {
|
||||||
"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n",
|
"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n",
|
||||||
|
|
||||||
'initdb' => "\tinitdb\n".
|
'initdb' => "\tinitdb\n".
|
||||||
"\t\t" . __("Use this command : cake schema run create -name DbAcl", true) . "\n",
|
"\t\t" . __("Use this command : cake schema run create DbAcl", true) . "\n",
|
||||||
|
|
||||||
'help' => "\thelp [<command>]\n" .
|
'help' => "\thelp [<command>]\n" .
|
||||||
"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
|
"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
|
||||||
|
|
|
@ -114,13 +114,13 @@ class SchemaShell extends Shell {
|
||||||
$snapshot = true;
|
$snapshot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$snapshot && file_exists($this->Schema->path . DS . 'schema.php')) {
|
if (!$snapshot && file_exists($this->Schema->path . DS . 'schema.php')) {
|
||||||
$snapshot = true;
|
$snapshot = true;
|
||||||
$result = $this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's');
|
$result = $this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's');
|
||||||
if($result === 'q') {
|
if ($result === 'q') {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if($result === 'o') {
|
if ($result === 'o') {
|
||||||
$snapshot = false;
|
$snapshot = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,11 +128,11 @@ class SchemaShell extends Shell {
|
||||||
$content = $this->Schema->read($options);
|
$content = $this->Schema->read($options);
|
||||||
$content['file'] = 'schema.php';
|
$content['file'] = 'schema.php';
|
||||||
|
|
||||||
if($snapshot === true) {
|
if ($snapshot === true) {
|
||||||
$Folder =& new Folder($this->Schema->path);
|
$Folder =& new Folder($this->Schema->path);
|
||||||
$result = $Folder->read();
|
$result = $Folder->read();
|
||||||
$count = 1;
|
$count = 1;
|
||||||
if(!empty($result[1])) {
|
if (!empty($result[1])) {
|
||||||
foreach ($result[1] as $file) {
|
foreach ($result[1] as $file) {
|
||||||
if (preg_match('/schema/', $file)) {
|
if (preg_match('/schema/', $file)) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -160,12 +160,12 @@ class SchemaShell extends Shell {
|
||||||
function dump() {
|
function dump() {
|
||||||
$write = false;
|
$write = false;
|
||||||
$Schema = $this->Schema->load();
|
$Schema = $this->Schema->load();
|
||||||
if(!$Schema) {
|
if (!$Schema) {
|
||||||
$this->err(__('Schema could not be loaded', true));
|
$this->err(__('Schema could not be loaded', true));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if (!empty($this->args[0])) {
|
if (!empty($this->args[0])) {
|
||||||
if($this->args[0] == 'true') {
|
if ($this->args[0] == 'true') {
|
||||||
$write = Inflector::underscore($this->Schema->name);
|
$write = Inflector::underscore($this->Schema->name);
|
||||||
} else {
|
} else {
|
||||||
$write = $this->args[0];
|
$write = $this->args[0];
|
||||||
|
@ -174,12 +174,12 @@ class SchemaShell extends Shell {
|
||||||
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
||||||
$contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:m:s') . " : ". time()."\n\n";
|
$contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:m:s') . " : ". time()."\n\n";
|
||||||
$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
|
$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
|
||||||
if($write) {
|
if ($write) {
|
||||||
if(strpos($write, '.sql') === false) {
|
if (strpos($write, '.sql') === false) {
|
||||||
$write .= '.sql';
|
$write .= '.sql';
|
||||||
}
|
}
|
||||||
$File = new File($this->Schema->path . DS . $write, true);
|
$File = new File($this->Schema->path . DS . $write, true);
|
||||||
if($File->write($contents)) {
|
if ($File->write($contents)) {
|
||||||
$this->out(sprintf(__('SQL dump file created in %s', true), $File->pwd()));
|
$this->out(sprintf(__('SQL dump file created in %s', true), $File->pwd()));
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
@ -205,24 +205,29 @@ class SchemaShell extends Shell {
|
||||||
|
|
||||||
$this->Dispatch->shiftArgs();
|
$this->Dispatch->shiftArgs();
|
||||||
|
|
||||||
if(isset($this->params['dry'])) {
|
$name = null;
|
||||||
|
if (isset($this->args[0])) {
|
||||||
|
$name = $this->args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->params['dry'])) {
|
||||||
$this->__dry = true;
|
$this->__dry = true;
|
||||||
$this->out(__('Performing a dry run.', true));
|
$this->out(__('Performing a dry run.', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array('file' => $this->Schema->file);
|
$options = array('name' => $name, 'file' => $this->Schema->file);
|
||||||
if(isset($this->params['s'])) {
|
if (isset($this->params['s'])) {
|
||||||
$options = array('file' => 'schema_'.$this->params['s'].'.php');
|
$options = array('file' => 'schema_'.$this->params['s'].'.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
$Schema = $this->Schema->load($options);
|
$Schema = $this->Schema->load($options);
|
||||||
if(!$Schema) {
|
if (!$Schema) {
|
||||||
$this->err(sprintf(__('%s could not be loaded', true), $options['file']));
|
$this->err(sprintf(__('%s could not be loaded', true), $this->Schema->file));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = null;
|
$table = null;
|
||||||
if(isset($this->args[1])) {
|
if (isset($this->args[1])) {
|
||||||
$table = $this->args[1];
|
$table = $this->args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +254,7 @@ class SchemaShell extends Shell {
|
||||||
$options = array();
|
$options = array();
|
||||||
$table = null;
|
$table = null;
|
||||||
$event = array_keys($Schema->tables);
|
$event = array_keys($Schema->tables);
|
||||||
if($table) {
|
if ($table) {
|
||||||
$event = array($table);
|
$event = array($table);
|
||||||
}
|
}
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
@ -260,16 +265,16 @@ class SchemaShell extends Shell {
|
||||||
$drop = $db->dropSchema($Schema, $table);
|
$drop = $db->dropSchema($Schema, $table);
|
||||||
|
|
||||||
$this->out($drop);
|
$this->out($drop);
|
||||||
if('y' == $this->in('Are you sure you want to drop tables and create your database?', array('y', 'n'), 'n')) {
|
if ('y' == $this->in('Are you sure you want to drop tables and create your database?', array('y', 'n'), 'n')) {
|
||||||
$create = $db->createSchema($Schema, $table);
|
$create = $db->createSchema($Schema, $table);
|
||||||
$this->out('Updating Database...');
|
$this->out('Updating Database...');
|
||||||
$contents = array_map('trim', explode(";", $drop. $create));
|
$contents = array_map('trim', explode(";", $drop. $create));
|
||||||
foreach($contents as $sql) {
|
foreach($contents as $sql) {
|
||||||
if($this->__dry === true) {
|
if ($this->__dry === true) {
|
||||||
$this->out($sql);
|
$this->out($sql);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($sql)) {
|
if (!empty($sql)) {
|
||||||
if(!$this->Schema->before(array('created'=> $event))) {
|
if (!$this->Schema->before(array('created'=> $event))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$db->_execute($sql)) {
|
if (!$db->_execute($sql)) {
|
||||||
|
@ -279,7 +284,7 @@ class SchemaShell extends Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!empty($errors)) {
|
if (!empty($errors)) {
|
||||||
$this->err($errors);
|
$this->err($errors);
|
||||||
} elseif ($this->__dry !== true) {
|
} elseif ($this->__dry !== true) {
|
||||||
$this->out(__('Database updated', true));
|
$this->out(__('Database updated', true));
|
||||||
|
@ -300,7 +305,7 @@ class SchemaShell extends Shell {
|
||||||
$Old = $this->Schema->read();
|
$Old = $this->Schema->read();
|
||||||
$compare = $this->Schema->compare($Old, $Schema);
|
$compare = $this->Schema->compare($Old, $Schema);
|
||||||
|
|
||||||
if(isset($compare[$table])) {
|
if (isset($compare[$table])) {
|
||||||
$compare = array($table => $compare[$table]);
|
$compare = array($table => $compare[$table]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,16 +314,16 @@ class SchemaShell extends Shell {
|
||||||
$db->fullDebug = true;
|
$db->fullDebug = true;
|
||||||
|
|
||||||
$contents = $db->alterSchema($compare, $table);
|
$contents = $db->alterSchema($compare, $table);
|
||||||
if(empty($contents)) {
|
if (empty($contents)) {
|
||||||
$this->out(__('Schema is up to date.', true));
|
$this->out(__('Schema is up to date.', true));
|
||||||
exit();
|
exit();
|
||||||
} elseif($this->__dry === true || 'y' == $this->in('Would you like to see the changes?', array('y', 'n'), 'y')) {
|
} elseif ($this->__dry === true || 'y' == $this->in('Would you like to see the changes?', array('y', 'n'), 'y')) {
|
||||||
$this->out($contents);
|
$this->out($contents);
|
||||||
}
|
}
|
||||||
if($this->__dry !== true) {
|
if ($this->__dry !== true) {
|
||||||
if('y' == $this->in('Are you sure you want to update your database?', array('y', 'n'), 'n')) {
|
if ('y' == $this->in('Are you sure you want to update your database?', array('y', 'n'), 'n')) {
|
||||||
$this->out('Updating Database...');
|
$this->out('Updating Database...');
|
||||||
if(!$this->Schema->before($compare)) {
|
if (!$this->Schema->before($compare)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($db->_execute($contents)) {
|
if ($db->_execute($contents)) {
|
||||||
|
|
|
@ -1,8 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
/* SVN FILE: $Id$ */
|
/* SVN FILE: $Id$ */
|
||||||
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
|
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
|
||||||
|
/**
|
||||||
|
* This is Acl Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for ACL
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create DbAcl
|
||||||
|
*
|
||||||
|
*/
|
||||||
class DbAclSchema extends CakeSchema {
|
class DbAclSchema extends CakeSchema {
|
||||||
|
|
||||||
var $name = 'DbAcl';
|
var $name = 'DbAcl';
|
||||||
|
|
58
cake/console/libs/templates/skel/config/sql/i18n.php
Normal file
58
cake/console/libs/templates/skel/config/sql/i18n.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/*i18n schema generated on: 2007-11-25 07:11:25 : 1196004805*/
|
||||||
|
/**
|
||||||
|
* This is i18n Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for i18n
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create i18n
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class i18nSchema extends CakeSchema {
|
||||||
|
|
||||||
|
var $name = 'i18n';
|
||||||
|
|
||||||
|
function before($event = array()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function after($event = array()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
var $i18n = array(
|
||||||
|
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary', 'extra' => 'auto_increment'),
|
||||||
|
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
|
||||||
|
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||||
|
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
|
||||||
|
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||||
|
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||||
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
55
cake/console/libs/templates/skel/config/sql/sessions.php
Normal file
55
cake/console/libs/templates/skel/config/sql/sessions.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/*Sessions schema generated on: 2007-11-25 07:11:54 : 1196004714*/
|
||||||
|
/**
|
||||||
|
* This is Sessions Schema file
|
||||||
|
*
|
||||||
|
* Use it to configure database for Sessions
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.app.config.sql
|
||||||
|
* @since CakePHP(tm) v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Using the Schema command line utility
|
||||||
|
* cake schema run create Sessions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SessionsSchema extends CakeSchema {
|
||||||
|
|
||||||
|
var $name = 'Sessions';
|
||||||
|
|
||||||
|
function before($event = array()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function after($event = array()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
var $cake_sessions = array(
|
||||||
|
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
|
||||||
|
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||||
|
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
|
||||||
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
|
@ -72,12 +72,12 @@ class CakeSchema extends Object {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param array $data optional load object properties
|
* @param array $options optional load object properties
|
||||||
*/
|
*/
|
||||||
function __construct($data = array()) {
|
function __construct($options = array()) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
if (empty($data['name'])) {
|
if (empty($options['name'])) {
|
||||||
$this->name = preg_replace('/schema$/i', '', get_class($this));
|
$this->name = preg_replace('/schema$/i', '', get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +85,11 @@ class CakeSchema extends Object {
|
||||||
$this->name = Inflector::camelize(Configure::read('App.dir'));
|
$this->name = Inflector::camelize(Configure::read('App.dir'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data['path'])) {
|
if (empty($options['path'])) {
|
||||||
$this->path = CONFIGS . 'sql';
|
$this->path = CONFIGS . 'sql';
|
||||||
}
|
}
|
||||||
$data = am(get_object_vars($this), $data);
|
$options = am(get_object_vars($this), $options);
|
||||||
$this->_build($data);
|
$this->_build($options);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Builds schema object properties
|
* Builds schema object properties
|
||||||
|
@ -146,11 +146,9 @@ class CakeSchema extends Object {
|
||||||
if (is_string($options)) {
|
if (is_string($options)) {
|
||||||
$options = array('path'=> $options);
|
$options = array('path'=> $options);
|
||||||
}
|
}
|
||||||
$options = am(
|
|
||||||
get_object_vars($this), $options
|
|
||||||
);
|
|
||||||
|
|
||||||
extract($options);
|
$this->_build($options);
|
||||||
|
extract(get_object_vars($this));
|
||||||
|
|
||||||
$class = $name .'Schema';
|
$class = $name .'Schema';
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
|
@ -162,8 +160,7 @@ class CakeSchema extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$Schema =& new $class();
|
$Schema =& new $class($options);
|
||||||
$this->_build($options);
|
|
||||||
return $Schema;
|
return $Schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue