本文整理匯總了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} ?");
}
示例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));
}