本文整理汇总了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));
}