/** * @access protected */ function &_perform($target, $target_name, $opt_list) { // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } // skelfile if (isset($opt_list['skelfile'])) { $skelfile = end($opt_list['skelfile']); } else { $skelfile = null; } // gateway if (isset($opt_list['gateway'])) { $gateway = 'GATEWAY_' . strtoupper(end($opt_list['gateway'])); if (defined($gateway)) { $gateway = constant($gateway); } else { return Ethna::raiseError('unknown gateway', 'usage'); } } else { $gateway = GATEWAY_WWW; } $r =& Ethna_Generator::generate($target, $basedir, $target_name, $skelfile, $gateway); if (Ethna::isError($r)) { printf("error occurred while generating skelton. please see also following error message(s)\n\n"); return $r; } $true = true; return $true; }
/** * @access public */ function perform() { $args =& $this->_parseArgList(); if (Ethna::isError($args)) { return $args; } $pear =& new Ethna_PearWrapper(); if (isset($args['pearopt'])) { $pear->setPearOpt($args['pearopt']); } if (isset($args['type']) && isset($args['name'])) { $target = isset($args['target']) ? $args['target'] : null; $channel = isset($args['channel']) ? $args['channel'] : null; $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd(); if ($target == 'master') { $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']); } else { $pkg_name = sprintf('App_Plugin_%s_%s', $args['type'], $args['name']); } $r =& $pear->init($target, $basedir, $channel); if (Ethna::isError($r)) { return $r; } $r =& $pear->doInfo($pkg_name); if (Ethna::isError($r)) { return $r; } } else { return Ethna::raiseError('invalid arguments', 'usage'); } return true; }
/** * generate message catalog. * * @access public */ function perform() { $r = $this->_getopt(array('basedir=', 'locale=', 'gettext')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } // locale if (isset($opt_list['locale'])) { $locale = end($opt_list['locale']); if (!preg_match('/^[A-Za-z_]+$/', $locale)) { return Ethna::raiseError("You specified locale, but invalid : {$locale}", 'usage'); } } else { $locale = 'ja_JP'; // default locale. } // use gettext ? $use_gettext = isset($opt_list['gettext']) ? true : false; // generate message catalog. $ret =& Ethna_Generator::generate('I18n', $basedir, $locale, $use_gettext, $arg_list); if (Ethna::isError($ret)) { printf("error occurred while generating skelton. please see also following error message(s)\n\n"); return $ret; } return $ret; }
/** * @access protected */ function _perform($target) { $r =& $this->_getopt(array('basedir=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // table_name $table_name = array_shift($arg_list); if ($table_name == null) { return Ethna::raiseError('table name isn\'t set.', 'usage'); } // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } $r =& Ethna_Generator::generate($target, $basedir, $table_name); if (Ethna::isError($r)) { printf("error occurred while generating skelton. please see also following error message(s)\n\n"); return $r; } return true; }
/** * show help * * @access public */ function perform() { $r = $this->_getopt(); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // action_name $handle_name = array_shift($arg_list); if (!strlen($handle_name)) { $handler_list = $this->eh->getHandlerList(); printf("usage: ethna [option] [command] [args...]\n\n"); printf("available options are as follows:\n\n"); printf(" -v, --version show version and exit\n"); printf("\navailable commands are as follows:\n\n"); foreach ($handler_list as $handler) { printf(" %s\n", $handler->getId()); } return true; } // getHandler $handler = $this->eh->getHandler($handle_name); if (Ethna::isError($handler) || $handler === false) { // command not found return Ethna::raiseError('command not found.', 'usage'); } echo $handler->getDescription(); return true; }
/** * add view * * @access public */ function perform() { $r =& $this->_getopt(array('basedir=', 'skelfile=', 'template')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // view_name $view_name = array_shift($arg_list); if ($view_name == null) { return Ethna::raiseError('view name isn\'t set.', 'usage'); } $r =& Ethna_Controller::checkViewName($view_name); if (Ethna::isError($r)) { return $r; } // add view $ret =& $this->_perform('View', $view_name, $opt_list); if (Ethna::isError($ret) || $ret === false) { return $ret; } // add template if (isset($opt_list['template'])) { $ret =& $this->_perform('Template', $view_name, $opt_list); if (Ethna::isError($ret) || $ret === false) { return $ret; } } return true; }
/** * add project:) * * @access public */ function perform() { $r = $this->_getopt(array('basedir=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // app_id $app_id = array_shift($arg_list); if ($app_id == null) { return Ethna::raiseError('project id isn\'t set.', 'usage'); } $r = Ethna_Controller::checkAppId($app_id); if (Ethna::isError($r)) { return $r; } // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } $r = Ethna_Generator::generate('Project', null, $app_id, $basedir); if (Ethna::isError($r)) { printf("error occurred while generating skelton. please see also error messages given above\n\n"); return $r; } printf("\nproject skelton for [%s] is successfully generated at [%s]\n\n", $app_id, $basedir); return true; }
/** * add action entry point * * @access public */ function perform() { $r = $this->_getopt(array('basedir=', 'skelfile=', 'gateway=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // action_name $action_name = array_shift($arg_list); if ($action_name == null) { return Ethna::raiseError('action name isn\'t set.', 'usage'); } $r = Ethna_Controller::checkActionName($action_name); if (Ethna::isError($r)) { return $r; } // add entry point $ret = $this->_perform('EntryPoint', $action_name, $opt_list); if (Ethna::isError($ret) || $ret === false) { return $ret; } // add action (no effects if already exists.) $ret = $this->_perform('Action', $action_name, $opt_list); if (Ethna::isError($ret) || $ret === false) { return $ret; } return true; }
/** * @access public */ function perform() { $r = $this->_getopt(array('basedir=', 'type=', 'plugin-package')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // plugin name $plugin_name = array_shift($arg_list); if (empty($plugin_name)) { return Ethna::raiseError('Please specify plugin Name.', 'usage'); } // plugin types $type = end($opt_list['type']); $types = explode(',', $type); if (empty($type)) { $types = array('v', 'f', 'sm'); // Validator, Filter, Smarty modifier. } // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } // no-ini file flag. $forpackage = isset($opt_list['plugin-package']) ? true : false; $r = Ethna_Generator::generate('CreatePlugin', NULL, $basedir, $types, $forpackage, $plugin_name); if (Ethna::isError($r)) { printf("error occurred while generating plugin skelton. please see also error messages given above\n\n"); return $r; } printf("\nplugin skelton for [%s] is successfully generated.\n\n", $plugin_name); return true; }
/** * コマンドの実装部分 * * テストケースファイル生成を行う * * @access protected * @return mixed 実行結果: TRUE: 成功 * Ethna_Error: エラー */ function &perform() { // get args. $r = $this->_getopt(array('basedir=', 'skelfile=')); if (Ethna::isError($r)) { return $r; } list($optlist, $arglist) = $r; $num = count($arglist); if ($num < 1 || $num > 3) { return Ethna::raiseError("Invalid Arguments.", 'usage'); } if (isset($optlist['skelfile'])) { $skelfile = end($optlist['skelfile']); } else { $skelfile = null; } $baseDir = isset($optlist['basedir']) ? $optlist['basedir'] : getcwd(); $name = $arglist[0]; $r =& Ethna_Generator::generate('Test', $baseDir, $skelfile, $name); if (Ethna::isError($r)) { return $r; } $true = true; return $true; }
/** * エントリポイントのスケルトンを生成する * * @access public * @param string $skelton スケルトンファイル名 * @param int $gateway ゲートウェイ * @return true|Ethna_Error true:成功 Ethna_Error:失敗 */ function &generate($action_name, $skelton = null, $gateway = GATEWAY_WWW) { $true = true; // entity switch ($gateway) { case GATEWAY_WWW: $entity = sprintf("%s/%s.%s", $this->ctl->getDirectory('www'), $action_name, $this->ctl->getExt('php')); break; case GATEWAY_CLI: $entity = sprintf("%s/%s.%s", $this->ctl->getDirectory('bin'), $action_name, $this->ctl->getExt('php')); break; default: $ret = Ethna::raiseError('add-entry-point accepts only GATEWAY_WWW or GATEWAY_CLI.'); return $ret; } // skelton if ($skelton === null) { switch ($gateway) { case GATEWAY_WWW: $skelton = 'skel.entry_www.php'; break; case GATEWAY_CLI: $skelton = 'skel.entry_cli.php'; break; } } if (file_exists($entity)) { printf("file [%s] already exists -> skip\n", $entity); return $true; } // macro $macro = array(); $macro['project_id'] = $this->ctl->getAppId(); $macro['action_name'] = $action_name; $macro['dir_app'] = $this->ctl->getDirectory('app'); // user macro $user_macro = $this->_getUserMacro(); $macro = array_merge($macro, $user_macro); // generate $ret = $this->_generateFile($skelton, $entity, $macro); if ($ret) { printf("action script(s) successfully created [%s]\n", $entity); } else { printf("[warning] file creation failed [%s]\n", $entity); return $true; // XXX: error handling } // chmod if ($gateway === GATEWAY_CLI) { // is needed? //$ret = Ethna_Util::chmod($entity, 0777); } return $true; }
public function resolveActionName(Request $request, string $default_action_name) { $action_name = (new Ethna_RequestWrapper($request))->getActionName($default_action_name); list($action_class_name, , ) = $this->getClassNames($action_name); if (is_null($action_class_name)) { $this->logger->end(); $r = Ethna::raiseError("undefined action [%s]", E_APP_UNDEFINED_ACTION, $action_name); throw new \Exception($r->getMessage()); } return $action_name; }
public function getUserByToken($token) { $ret = $this->db->getRow(sprintf('SELECT * FROM %s WHERE token = ?', $this->_table), $token); if (!$ret) { return Ethna::raiseError("user not found"); } if (Ethna::isError($ret)) { return $ret; } return $ret; }
/** * アクションのスケルトンを生成する * * @access public * @param string $action_name アクション名 * @param string $skelton スケルトンファイル名 * @param int $gateway ゲートウェイ * @return true|Ethna_Error true:成功 Ethna_Error:失敗 */ function generate($action_name, $skelton = null, $gateway = GATEWAY_WWW) { $action_dir = $this->ctl->getActiondir($gateway); $action_class = $this->ctl->getDefaultActionClass($action_name, $gateway); $action_form = $this->ctl->getDefaultFormClass($action_name, $gateway); $action_path = $this->ctl->getDefaultActionPath($action_name); // entity $entity = $action_dir . $action_path; Ethna_Util::mkdir(dirname($entity), 0755); // skelton if ($skelton === null) { switch ($gateway) { case GATEWAY_WWW: $skelton = "skel.action.php"; break; case GATEWAY_CLI: $skelton = "skel.action_cli.php"; break; case GATEWAY_XMLRPC: $skelton = "skel.action_xmlrpc.php"; break; default: $err = Ethna::raiseError('unknown gateway.'); return $err; } } // macro $macro = array(); $macro['project_id'] = $this->ctl->getAppId(); $macro['action_name'] = $action_name; $macro['action_class'] = $action_class; $macro['action_form'] = $action_form; $macro['action_path'] = $action_path; // user macro $user_macro = $this->_getUserMacro(); $macro = array_merge($macro, $user_macro); // generate if (file_exists($entity)) { printf("file [%s] already exists -> skip\n", $entity); } else { if ($this->_generateFile($skelton, $entity, $macro) == false) { printf("[warning] file creation failed [%s]\n", $entity); } else { printf("action script(s) successfully created [%s]\n", $entity); } } $true = true; return $true; }
/** * 連想配列をもとに AppObject を生成し add() します。 * * @author Seiya Konno <*****@*****.**> * @access protected * @param array $array * @param bool $add */ function createObject($array = array(), $add = true) { if (is_null($this->name)) { return Ethna::raiseError('AppManager::$name が設定されていません。'); } $this->backend->log(LOG_DEBUG, var_export($array, true)); $appObject = $this->backend->getObject($this->name); foreach ($array as $key => $value) { $appObject->set($key, $value); } if ($add) { $result = $appObject->add(); return Ethna::isError($result) ? $result : $appObject; } return $appObject; }
/** * @access protected */ function &_perform($target, $target_name, $opt_list) { // basedir if (isset($opt_list['basedir'])) { $basedir = realpath(end($opt_list['basedir'])); } else { $basedir = getcwd(); } // skelfile if (isset($opt_list['skelfile'])) { $skelfile = end($opt_list['skelfile']); } else { $skelfile = null; } // gateway if (isset($opt_list['gateway'])) { $gateway = 'GATEWAY_' . strtoupper(end($opt_list['gateway'])); if (defined($gateway)) { $gateway = constant($gateway); } else { return Ethna::raiseError('unknown gateway', 'usage'); } } else { $gateway = GATEWAY_WWW; } // possible target is Action, View. $r =& Ethna_Generator::generate($target, $basedir, $target_name, $skelfile, $gateway); if (Ethna::isError($r)) { printf("error occurred while generating skelton. please see also following error message(s)\n\n"); return $r; } // // if specified, generate corresponding testcase, // except for template. // if ($target != 'Template' && isset($opt_list['with-unittest'])) { $testskel = isset($opt_list['unittestskel']) ? end($opt_list['unittestskel']) : null; $r =& Ethna_Generator::generate("{$target}Test", $basedir, $target_name, $testskel, $gateway); if (Ethna::isError($r)) { printf("error occurred while generating action test skelton. please see also following error message(s)\n\n"); return $r; } } $true = true; return $true; }
/** * add view test * * @access public */ function perform() { $r =& $this->_getopt(array('basedir=', 'skelfile=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // view_name $view_name = array_shift($arg_list); if ($view_name == null) { return Ethna::raiseError('view name isn\'t set.', 'usage'); } $r =& Ethna_Controller::checkViewName($view_name); if (Ethna::isError($r)) { return $r; } $ret =& $this->_perform('ViewTest', $view_name, $opt_list); return $ret; }
public function post($content, $content_type, $title = "", $token = false) { $user_id = 0; if ($token) { $user = $this->user->getUserByToken($token); if (Ethna::isError($user)) { return Ethna::raiseError('token invalid: ' . $user->getMessage()); } $user_id = $user['id']; } elseif ($user = $this->session->get('user')) { $user_id = $user['id']; } $session_id = session_id(); $ret = $this->db->autoExecute($this->_table, array('user_id' => $user_id, 'session_id' => $session_id, 'content_type' => $content_type, 'content' => $content, 'title' => $title, 'modified' => date('Y-m-d H:i:s'), 'created' => date('Y-m-d H:i:s')), 'INSERT'); if (!$ret) { return Ethna::raiseError('Error: post failed.'); } $id = $this->db->getOne('SELECT LAST_INSERT_ID()'); return $id; }
/** * add template * * @access public */ function perform() { $r =& $this->_getopt(array('basedir=', 'skelfile=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // template $template = array_shift($arg_list); if ($template == null) { return Ethna::raiseError('template name isn\'t set.', 'usage'); } $r =& Ethna_Controller::checkViewName($template); // XXX: use checkViewName(). if (Ethna::isError($r)) { return $r; } // add template $ret =& $this->_perform('Template', $template, $opt_list); return $ret; }
/** * Ethna_CacheMaangerクラスのインスタンスを取得する * * @access public * @param string $type キャッシュタイプ('localfile', 'memcache'...) * @return object Ethna_CacheMaanger Ethna_CacheManagerオブジェクト */ function &getInstance($type) { static $instance = array(); if (array_key_exists($type, $instance)) { return $instance[$type]; } // TODO: use plugin $class_name = sprintf("Ethna_CacheManager_%s", ucfirst(strtolower($type))); $class_file = sprintf("%s/CacheManager/%s.php", dirname(__FILE__), $class_name); if (file_exists($class_file) == false) { $retval = Ethna::raiseError("invalid cache type: no such file ({$class_file})", E_CACHE_INVALID_TYPE); return $retval; } include_once $class_file; if (class_exists($class_name) == false) { $retval = Ethna::raiseError("invalid cache type: class is not defined ({$class_name})", E_CACHE_INVALID_TYPE); return $retval; } $instance[$type] =& new $class_name(); return $instance[$type]; }
/** * check arguments * * @access private */ function _validateArgList() { $arg_list = array(); if (count($this->arg_list) < 1) { return Ethna::raiseError('too few argments', 'usage'); } else { if (count($this->arg_list) > 2) { return Ethna::raiseError('too many argments', 'usage'); } else { if (count($this->arg_list) == 1) { $arg_list[] = $this->arg_list[0]; $arg_list[] = getcwd(); } else { $arg_list = $this->arg_list; } } } if (is_dir($arg_list[1]) == false) { return Ethna::raiseError("no such directory [{$arg_list[1]}]"); } return $arg_list; }
/** * check arguments * * @access private */ function _validateArgList() { $arg_list = array(); if (count($this->arg_list) < 1) { return Ethna::raiseError('too few argments', 'usage'); } else { if (count($this->arg_list) > 2) { return Ethna::raiseError('too many argments', 'usage'); } else { if (count($this->arg_list) == 1) { $arg_list[] = $this->arg_list[0]; $arg_list[] = getcwd(); } else { $arg_list = $this->arg_list; } } } // TODO: check action name(?) - how it would be easy and pluggable if (is_dir($arg_list[1]) == false) { return Ethna::raiseError("no such directory [{$arg_list[1]}]"); } return $arg_list; }
/** * Display the template * * @param string $template template name * @param bool $capture if true, not display but return as string * * @access public */ public function perform($template = null, $capture = false) { if ($template === null && $this->template === null) { return Ethna::raiseWarning('template is not defined'); } if ($template !== null) { $this->template = $template; } try { if (is_absolute_path($this->template) && is_readable($this->template) || is_readable($this->template_dir . $this->template)) { if ($capture === true) { $captured = $this->engine->fetch($this->template); return $captured; } else { $this->engine->display($this->template); } } else { return Ethna::raiseWarning('template not found ' . $this->template); } } catch (SmartyCompilerException $e) { $this->logger->log(LOG_ERR, "smarty compile error: msg='{$e->getMessage()}'"); return Ethna::raiseError("smarty compile error: msg='{$e->getMessage()}'", 500); } }
/** * get an object list of all available handlers * * @access public */ function getHandlerList() { $handler_dir = $this->_getHnalderDir(); $dh = opendir($handler_dir); if ($dh === false) { return Ethna::raiseError("failed opening handlers' dir [{$handler_dir}]"); } $handler_list = array(); while (($file = readdir($dh)) !== false) { $id = $this->_getIdFromFile($file); if (Ethna::isError($id)) { // seems unknown type of files continue; } $handler =& $this->getHandler($id); if (Ethna::isError($handler)) { continue; } $handler_list[] = $handler; } closedir($dh); usort($handler_list, array($this, "_handler_sort_callback")); return $handler_list; }
/** * @access private */ function &_parseArgList() { $r =& $this->_getopt(array('inifile=', 'skelfile=', 'workdir=')); if (Ethna::isError($r)) { return $r; } list($opt_list, $arg_list) = $r; // inifile if (isset($opt_list['inifile']) && is_readable(end($opt_list['inifile']))) { $ini = parse_ini_file(end($opt_list['inifile']), true); } else { return Ethna::raiseError('give a valid inifile.'); } // skelfile if (isset($opt_list['skelfile']) && is_readable(end($opt_list['skelfile']))) { $skelfile = end($opt_list['skelfile']); } else { return Ethna::raiseError('give a valid filename of plugin skelton file.'); } // workdir if (isset($opt_list['workdir'])) { $workdir = end($opt_list['workdir']); } else { $workdir = getcwd(); } return array($ini, $skelfile, $workdir); }
/** * 解析済みのメッセージ処理関数の情報を元に、カタログファイ * ルを生成します。 生成先は以下のパスになる。 * [appid]/[locale_dir]/[locale_name]/LC_MESSAGES/[locale_name].[ini|po] * * @access protected * @param string $locale 生成するカタログのロケール * @param int $use_gettext gettext 使用フラグ * true ならgettext のカタログ生成 * false ならEthna組み込みのカタログ生成 * @return true|Ethna_Error true:成功 Ethna_Error:失敗 */ function _generateFile() { $outfile_path = $this->_get_output_file(); $skel = $this->use_gettext ? 'locale/skel.msg.po' : 'locale/skel.msg.ini'; $resolved = $this->_resolveSkelfile($skel); if ($resolved === false) { return Ethna::raiseError("skelton file [%s] not found.\n", $skel); } else { $skel = $resolved; } $contents = file_get_contents($skel); $macro['project_id'] = $this->ctl->getAppId(); $macro['locale_name'] = $this->locale; $macro['now_date'] = strftime('%Y-%m-%d %H:%M%z'); foreach ($macro as $k => $v) { $contents = preg_replace("/{\\\${$k}}/", $v, $contents); } // generate file contents foreach ($this->tokens as $file_path => $tokens) { $is_first_loop = false; foreach ($tokens as $token) { $token_str = $token['token_str']; $token_line = $token['linenum']; $token_line = $token_line !== false ? ":{$token_line}" : ''; $translation = $token['translation']; if ($this->use_gettext) { $contents .= "#: {$file_path}{$token_line}\n" . "msgid \"{$token_str}\"\n" . "msgstr \"{$translation}\"\n\n"; } else { if ($is_first_loop === false) { $contents .= "\n; {$file_path}\n"; $is_first_loop = true; } $contents .= "\"{$token_str}\" = \"{$translation}\"\n"; } } } // finally write. $outfile_dir = dirname($outfile_path); if (!is_dir($outfile_dir)) { Ethna_Util::mkdir($outfile_dir, 0755); } $wfp = @fopen($outfile_path, "w"); if ($wfp == null) { return Ethna::raiseError("unable to open file: {$outfile_path}"); } if (fwrite($wfp, $contents) === false) { fclose($wfp); return Ethna::raiseError("unable to write contents to {$outfile_path}"); } fclose($wfp); printf("Message catalog template successfully created [%s]\n", $outfile_path); return true; }
/** * クエリを発行する * * @access private * @param string $query SQL文 * @return mixed DB_Result:結果オブジェクト Ethna_Error:エラー */ function _query($query, $inputarr = false) { $this->logger->log(LOG_DEBUG, $query); $r = $this->db->execute($query, $inputarr); if ($r === false) { $error = Ethna::raiseError('エラー SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->ErrorNo(), $this->db->ErrorMsg()); return $error; } return $r; }
/** * キャッシュデータのロックを解除する * * @access public * @param string $key キャッシュキー * @param string $namespace キャッシュネームスペース * @return bool true:成功 false:失敗 */ public function unlock($key, $namespace = null) { $this->_getMemcache($key, $namespace); if ($this->memcache == null) { return Ethna::raiseError('memcache server not available', E_CACHE_LOCK_ERROR); } $namespace = $this->getNamespace($namespace); $cache_key = "lock::" . $this->_getCacheKey($namespace, $key); $this->memcache->delete($cache_key, -1); }
/** * 指定されたDBキーに対応する(当該DBオブジェクトを格納するための)メンバ変数名を取得する * * 正直もう要らないのですが、後方互換性維持のために一応残してある状態です * (Ethna_AppManagerクラスなどで、$this->dbとかしている箇所が少なからずあ * るので) * * @access private * @param string $db_key DBキー * @return mixed string:メンバ変数名 Ethna_Error:不正なDB種別 */ function _getDBVarname($db_key = "") { $r = $this->controller->getDBType($db_key); if (is_null($r)) { return Ethna::raiseError("Undefined DB Type [%s]", E_DB_INVALIDTYPE, $db_key); } if ($db_key == "") { $db_varname = ""; } else { $db_varname = sprintf("%s", strtolower($db_key)); } return $db_varname; }
/** * クエリを発行する * * @access private * @param string $query SQL文 * @return mixed DB_Result:結果オブジェクト Ethna_Error:エラー */ function _query($query) { $this->logger->log(LOG_DEBUG, "{$query}"); $r = $this->db->query($query); if (DB::isError($r)) { if ($r->getCode() == DB_ERROR_ALREADY_EXISTS) { $error = Ethna::raiseNotice('Unique Constraint Error SQL[%s]', E_DB_DUPENT, $query, $this->db->errorNative(), $r->getUserInfo()); } else { $error = Ethna::raiseError('Query Error SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->errorNative(), $r->getUserInfo()); } return $error; } return $r; }