本文整理汇总了PHP中AkInflector::tableize方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::tableize方法的具体用法?PHP AkInflector::tableize怎么用?PHP AkInflector::tableize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::tableize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installAndIncludeModels
function installAndIncludeModels($models = array())
{
$args = func_get_args();
$models = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args[0]))) : array();
$default_options = array('instantiate' => true);
$options = is_array($models[count($models)-1]) ? array_pop($models) : array();
$options = array_merge($default_options, $options);
foreach ($models as $model){
require_once(AK_APP_DIR.DS.'installers'.DS.(empty($this->module)?'':$this->module.DS).AkInflector::underscore($model).'_installer.php');
require_once(AK_MODELS_DIR.DS.AkInflector::underscore($model).'.php');
$installer_name = $model.'Installer';
$installer = new $installer_name();
$installer->uninstall();
$installer->install();
if($this->insert_models_data || !empty($options['populate'])){
$this->populateTables(AkInflector::tableize($model));
}
if($this->instantiate_models || !empty($options['instantiate'])){
$this->instantiateModel($model);
}
}
if(isset($_SESSION['__activeRecordColumnsSettingsCache'])){
unset($_SESSION['__activeRecordColumnsSettingsCache']);
}
}
示例2: _preloadPaths
function _preloadPaths()
{
$this->class_name = AkInflector::camelize($this->class_name);
$this->assignVarToTemplate('class_name', $this->class_name);
$this->table_name = AkInflector::tableize($this->class_name);
$this->underscored_model_name = AkInflector::underscore($this->class_name);
$this->model_path = 'app' . DS . 'models' . DS . $this->underscored_model_name . '.php';
$this->installer_path = 'app' . DS . 'installers' . DS . $this->underscored_model_name . '_installer.php';
}
示例3: _createNewTestingModelDatabase
function _createNewTestingModelDatabase($test_model_name)
{
static $shutdown_called;
// Create a data dictionary object, using this connection
$db =& AK::db();
//$db->debug = true;
$table_name = AkInflector::tableize($test_model_name);
if (in_array($table_name, (array) $db->MetaTables())) {
return false;
}
switch ($table_name) {
case 'ak_test_people':
$table = array('table_name' => 'ak_test_people', 'fields' => 'id I AUTO KEY,
user_name C(32),
first_name C(200),
last_name C(200),
phone_number I(18),
city C(40),
state C(40),
email C(150),
country C(2),
sex C(1),
birth T,
age I(3),
password C(32),
tos L(1),
score I(3),
comments X,
created_at T,
updated_at T,
expires T', 'index_fileds' => 'id', 'table_options' => array('mysql' => 'TYPE=InnoDB', 'REPLACE'));
break;
default:
return false;
break;
}
$dict = NewDataDictionary($db);
$sqlarray = $dict->CreateTableSQL($table['table_name'], $table['fields'], $table['table_options']);
$dict->ExecuteSQLArray($sqlarray);
if (isset($table['index_fileds'])) {
$sqlarray = $dict->CreateIndexSQL('idx_' . $table['table_name'], $table['table_name'], $table['index_fileds']);
$dict->ExecuteSQLArray($sqlarray);
}
$db->CreateSequence('seq_' . $table['table_name']);
$this->_testing_model_databases_to_delete[] = $table_name;
if (!isset($shutdown_called)) {
$shutdown_called = true;
register_shutdown_function(array(&$this, '_deleteTestingModelDatabases'));
}
//$db->debug = false;
return true;
}
示例4: _createNewTestingModelDatabase
function _createNewTestingModelDatabase($test_model_name)
{
static $shutdown_called;
// Create a data dictionary object, using this connection
$db =& AK::db();
//$db->debug = true;
$table_name = AkInflector::tableize($test_model_name);
if(in_array($table_name, (array)$db->MetaTables())){
return false;
}
switch ($table_name) {
case 'ak_test_todo_items':
$table =
array(
'table_name' => 'ak_test_todo_items',
'fields' => 'id I AUTO KEY,
position I(20),
task X,
due_time T,
created_at T,
expires T,
updated_at T,
new_position I(10)',
'index_fileds' => 'id',
'table_options' => array('mysql' => 'TYPE=InnoDB', 'REPLACE')
);
break;
default:
return false;
break;
}
$dict = NewDataDictionary($db);
$sqlarray = $dict->CreateTableSQL($table['table_name'], $table['fields'], $table['table_options']);
$dict->ExecuteSQLArray($sqlarray);
if(isset($table['index_fileds'])){
$sqlarray = $dict->CreateIndexSQL('idx_'.$table['table_name'], $table['table_name'], $table['index_fileds']);
$dict->ExecuteSQLArray($sqlarray);
}
$db->CreateSequence('seq_'.$table['table_name']);
$this->_testing_model_databases_to_delete[] = $table_name;
if(!isset($shutdown_called)){
$shutdown_called = true;
register_shutdown_function(array(&$this,'_deleteTestingModelDatabases'));
}
//$db->debug = false;
return true;
}
示例5: _setupCloner
function _setupCloner()
{
$this->clone_setup_done = true;
$this->class_to_clone = AkInflector::underscore($this->class_to_clone);
$this->class_name = AkInflector::underscore($this->class_name);
$this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
//AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
$this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
foreach ($this->_getControllerViews() as $view_file) {
$this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
}
$this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
$this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
}
}
示例6: array
function &addAssociated($association_id, $options = array())
{
$default_options = array('class_name' => empty($options['class_name']) ? AkInflector::camelize($association_id) : $options['class_name'], 'foreign_key' => empty($options['foreign_key']) ? AkInflector::singularize($this->Owner->getTableName()) . '_id' : $options['foreign_key'], 'remote' => false, 'instantiate' => false, 'conditions' => false, 'include_conditions_when_included' => true, 'order' => false, 'include_order_when_included' => true, 'dependent' => false, 'counter_cache' => false);
$options = array_merge($default_options, $options);
$options['table_name'] = empty($options['table_name']) ? AkInflector::tableize($options['class_name']) : $options['table_name'];
$this->setOptions($association_id, $options);
$this->addModel($association_id, new AkAssociatedActiveRecord());
$associated =& $this->getModel($association_id);
$this->setAssociatedId($association_id, $associated->getId());
$associated =& $this->_build($association_id, &$associated, false);
$this->_saveLoadedHandler($association_id, $associated);
if ($options['instantiate']) {
$associated =& $this->addModel($association_id, new $options['class_name']($options['foreign_key'] . ' = ' . $this->Owner->quotedId()));
}
return $associated;
}
示例7: clear
function clear($table, $environment = AK_ENVIRONMENT)
{
$modelName = AkInflector::singularize(AkInflector::classify($table));
$cacheFileName = AkDbSchemaCache::_generateCacheFileName($modelName, $environment);
//echo "Cleaning cache: $cacheFileName\n";
if (file_exists($cacheFileName)) {
@unlink($cacheFileName);
}
AkDbSchemaCache::_get($modelName, $environment, false, false);
$tableName = AkInflector::tableize($table);
$databaseInternalsFileName = AkDbSchemaCache::_generateCacheFileName('database_table_internals_' . $tableName);
//echo "Cleaning cache: $databaseInternalsFileName\n";
if (file_exists($databaseInternalsFileName)) {
@unlink($databaseInternalsFileName);
}
AkDbSchemaCache::_get('database_table_internals_' . $tableName, $environment, false, false);
}
示例8: _preloadPaths
public function _preloadPaths()
{
if (!isset($this->active_document)) {
$this->active_document = isset($this->activedocument) || isset($this->ad) || isset($this->ActiveDocument);
}
$this->class_name = AkInflector::camelize($this->class_name);
$this->table_columns = trim(join(' ', (array) @$this->table_columns));
$this->assignVarToTemplate('table_columns', $this->table_columns);
$this->table_name = AkInflector::tableize($this->class_name);
$this->underscored_model_name = AkInflector::underscore($this->class_name);
$this->model_path = 'app' . DS . 'models' . DS . $this->underscored_model_name . '.php';
$this->installer_path = 'app' . DS . 'installers' . DS . $this->underscored_model_name . '_installer.php';
$this->test_file_name = AkInflector::underscore($this->class_name) . '_test.php';
$this->assignVarToTemplate('class_name', $this->class_name);
$this->assignVarToTemplate('test_file_name', $this->test_file_name);
$this->assignVarToTemplate('model_type', $this->active_document ? 'AkActiveDocument' : 'ActiveRecord');
}
示例9: _setDefaults
private function _setDefaults()
{
$this->class_name = AkInflector::camelize($this->class_name);
$this->table_name = AkInflector::tableize($this->class_name);
$this->file_name = AkInflector::underscore($this->class_name);
$this->controller_class_name = AkInflector::pluralize($this->class_name);
$this->controller_file_name = AkInflector::toControllerFilename($this->controller_class_name);
$this->table_columns = trim(join(' ', (array) @$this->table_columns));
$this->assignVarToTemplate('attributes', $this->_getModelAttributesForViews());
$this->assignVarToTemplate('class_name', $this->class_name);
$this->assignVarToTemplate('table_name', $this->table_name);
$this->assignVarToTemplate('plural_name', $this->table_name);
$this->assignVarToTemplate('singular_name', AkInflector::singularize($this->table_name));
$this->assignVarToTemplate('file_name', $this->file_name);
$this->assignVarToTemplate('table_columns', $this->table_columns);
$this->assignVarToTemplate('controller_class_name', $this->controller_class_name);
}
示例10: test_simple_tableize
public function test_simple_tableize()
{
$this->assertEqual('Pictures',AkInflector::pluralize('Picture'));
$this->assertEqual('pictures',AkInflector::tableize('picture'));
}
示例11: getClassForDatabaseTableMapping
/**
* This method retrieves current class name that will be used to map
* your database to this object.
*/
function getClassForDatabaseTableMapping()
{
$class_name = get_class($this);
if(is_subclass_of($this,'akactiverecord') || is_subclass_of($this,'AkActiveRecord')){
$parent_class = get_parent_class($this);
while (substr(strtolower($parent_class),-12) != 'activerecord'){
$class_name = $parent_class;
$parent_class = get_parent_class($parent_class);
}
}
$class_name = $this->_getModelName($class_name);
// This is an Active Record Inheritance so we set current table to parent table.
if(!empty($class_name) && strtolower($class_name) != 'activerecord'){
$this->_inheritanceClassName = $class_name;
@$this->setTableName(AkInflector::tableize($class_name), false);
}
return $class_name;
}
示例12: findFixtureForModel
function findFixtureForModel($model_name)
{
$fixture_file_name = AkInflector::tableize($model_name) . '.yaml';
$include_path = array(AK_PHPUNIT_TESTSUITE_FIXTURES, AK_APP_DIR . DS . 'data');
return PHPUnit_Akelos_autoload::searchFilenameInPath($include_path, $fixture_file_name);
}
示例13: Test_of_tableize
function Test_of_tableize()
{
foreach ($this->ClassNameToTableName as $class_name => $table_name) {
$this->assertEqual($table_name, AkInflector::tableize($class_name));
}
}
示例14: tableize
public function tableize()
{
return AkInflector::tableize($this->value);
}
示例15: array
function &addAssociated($association_id, $options = array())
{
$default_options = array('class_name' => empty($options['class_name']) ? AkInflector::modulize($association_id) : $options['class_name'], 'table_name' => false, 'join_table' => false, 'join_class_name' => false, 'foreign_key' => false, 'association_foreign_key' => false, 'conditions' => false, 'order' => false, 'join_class_extends' => 'AkActiveRecord', 'finder_sql' => false, 'delete_sql' => false, 'insert_sql' => false, 'include' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false, 'instantiate' => false);
$options = array_merge($default_options, $options);
$owner_name = $this->Owner->getModelName();
$owner_table = $this->Owner->getTableName();
$associated_name = $options['class_name'];
$associated_table_name = $options['table_name'] = empty($options['table_name']) ? AkInflector::tableize($associated_name) : $options['table_name'];
$join_tables = array($owner_table, $associated_table_name);
sort($join_tables);
$options['join_table'] = empty($options['join_table']) ? join('_', $join_tables) : $options['join_table'];
$options['join_class_name'] = empty($options['join_class_name']) ? join(array_map(array('AkInflector', 'modulize'), array_map(array('AkInflector', 'singularize'), $join_tables))) : $options['join_class_name'];
$options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($owner_name) . '_id' : $options['foreign_key'];
$options['association_foreign_key'] = empty($options['association_foreign_key']) ? AkInflector::underscore($associated_name) . '_id' : $options['association_foreign_key'];
$Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
$Collection->setOptions($association_id, $options);
$this->addModel($association_id, $Collection);
if ($options['instantiate']) {
$associated =& $Collection->load();
}
$this->setAssociatedId($association_id, $options['handler_name']);
$Collection->association_id = $association_id;
$Collection->_loadJoinObject() ? null : trigger_error(Ak::t('Could find join model %model_name for hasAndBelongsToMany association %id', array('%table_name' => $options['join_class_name'], 'id' => $this->association_id)), E_USER_ERROR);
return $Collection;
}