当前位置: 首页>>代码示例>>PHP>>正文


PHP Strings::tableNameToModelName方法代码示例

本文整理汇总了PHP中Strings::tableNameToModelName方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::tableNameToModelName方法的具体用法?PHP Strings::tableNameToModelName怎么用?PHP Strings::tableNameToModelName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Strings的用法示例。


在下文中一共展示了Strings::tableNameToModelName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: searchAction

 public function searchAction()
 {
     try {
         $tableName = $this->request->getPost('table');
         $field = $this->request->getPost('field');
         $search = $this->request->getPost('search');
         $modelName = Strings::tableNameToModelName($tableName);
         $results = array();
         if (class_exists($modelName)) {
             $pri = $modelName::primaryKeyName();
             $condition = '';
             if ($field) {
                 if ($search) {
                     $condition = "{$field} LIKE '%{$search}%'";
                     if (is_numeric($search)) {
                         $condition .= " or {$pri}={$search}";
                     }
                     $results = $modelName::find(array('conditions' => $condition, "limit" => 20));
                     $results = $results->toArray();
                 }
             }
             // TODO: Merge two parts
             parent::result(array('results' => $results, 'SQL' => $condition, 'key' => $pri));
         } else {
             parent::error(-2, "{$modelName} does not exists");
         }
     } catch (Exception $e) {
         parent::error(-3, "{$e}");
     }
     parent::error(-1, "{$modelName} ?");
 }
开发者ID:healerkx,项目名称:AdminBuildr,代码行数:31,代码来源:AjaxController.php

示例2: previewAction

 public function previewAction()
 {
     $p = $this->request->getPost();
     $prefix = $p['prefix'];
     $tableName = $p['table_name'];
     if ($prefix) {
         $tableName = "{$prefix}_{$tableName}";
     }
     $modelName = Strings::tableNameToModelName($tableName);
     $path = ApplicationConfig::getConfig('product')['path'] . '\\www';
     $this->createModelConfigFile($path, $modelName, $p);
     $configPath = ApplicationConfig::getConfigPath('config.json');
     $cmdLine = "--prefix={$prefix} --table={$tableName} --config=\"{$configPath}\"";
     $c = Python3::run("build_mvc.py", $cmdLine);
     $targetHost = ApplicationConfig::getConfig('product')['host'];
     $testListUrl = "{$targetHost}/{$modelName}";
     parent::result(array('model' => $modelName, 'files' => json_decode($c), 'cmd_line' => $cmdLine, 'test_list_url' => $testListUrl, 'build' => $c));
 }
开发者ID:healerkx,项目名称:AdminBuildr,代码行数:18,代码来源:AbModuleController.php


注:本文中的Strings::tableNameToModelName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。