當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。