本文整理汇总了PHP中jDb::getTools方法的典型用法代码示例。如果您正苦于以下问题:PHP jDb::getTools方法的具体用法?PHP jDb::getTools怎么用?PHP jDb::getTools使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jDb
的用法示例。
在下文中一共展示了jDb::getTools方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execSQLScript
/**
* import a sql script into the given profile.
*
* The name of the script should be store in install/sql/$name.databasetype.sql
* in the directory of the component. (replace databasetype by mysql, pgsql etc.)
*
* @param string $name the name of the script, without suffixes
*/
public function execSQLScript($name, $profile = '')
{
$tools = jDb::getTools($profile);
$p = jDb::getProfile($profile);
$driver = $p['driver'];
if ($driver == 'pdo') {
preg_match('/^(\\w+)\\:.*$/', $p['dsn'], $m);
$driver = $m[1];
}
$tools->execSQLScript($this->path . 'install/sql/' . $name . '.' . $driver . '.sql');
}
示例2: run
public function run()
{
jxs_init_jelix_env();
$entrypoint = $this->getParam('entrypoint');
if (!file_exists(JELIX_APP_WWW_PATH . $entrypoint . '.php')) {
try {
$cmd = jxs_load_command('createentrypoint');
$cmd->init(array(), array('name' => $entrypoint));
$cmd->run();
} catch (Exception $e) {
echo "The entrypoint has not been created because of this error: " . $e->getMessage() . ". No other files have been created.\n";
}
}
$inifile = new jIniMultiFilesModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', JELIX_APP_CONFIG_PATH . $entrypoint . '/config.ini.php');
$inifile->setValue('html', 'adminHtmlResponse', 'responses');
$inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses');
$inifile->setValue('auth', $entrypoint . '/auth.coord.ini.php', 'coordplugins');
$inifile->setValue('jacl2', $entrypoint . '/jacl2.coord.ini.php', 'coordplugins');
$inifile->setValue('startModule', 'master_admin');
$inifile->setValue('startAction', 'default:index');
$modulePath = $inifile->getValue("modulesPath");
if (strpos($modulePath, 'lib:jelix-admin-modules') === false) {
$inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,' . $modulePath);
}
$inifile->setValue('driver', 'db', 'acl2');
$urlconf = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints', null, true);
if ($urlconf === null || $urlconf == '') {
// in defaultconfig
$inifile->setValue($entrypoint, 'jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints', null, true);
// in the config of the entry point
$inifile->setValue($entrypoint, 'jacl2db~*@classic, jauth~*@classic, jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints');
} else {
$urlconf2 = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints');
if (strpos($urlconf, 'jacl2db_admin~*@classic') === false) {
$urlconf .= ',jacl2db_admin~*@classic';
}
if (strpos($urlconf, 'jauthdb_admin~*@classic') === false) {
$urlconf .= ',jauthdb_admin~*@classic';
}
if (strpos($urlconf, 'master_admin~*@classic') === false) {
$urlconf .= ',master_admin~*@classic';
}
if (strpos($urlconf2, 'jacl2db_admin~*@classic') === false) {
$urlconf2 .= ',jacl2db_admin~*@classic';
}
if (strpos($urlconf2, 'jauthdb_admin~*@classic') === false) {
$urlconf2 .= ',jauthdb_admin~*@classic';
}
if (strpos($urlconf2, 'master_admin~*@classic') === false) {
$urlconf2 .= ',master_admin~*@classic';
}
if (strpos($urlconf2, 'jacl2db~*@classic') === false) {
$urlconf2 .= ',jacl2db~*@classic';
}
if (strpos($urlconf2, 'jauth~*@classic') === false) {
$urlconf2 .= ',jauth~*@classic';
}
$inifile->setValue($entrypoint, $urlconf, 'simple_urlengine_entrypoints', null, true);
$inifile->setValue($entrypoint, $urlconf2, 'simple_urlengine_entrypoints');
}
if (null == $inifile->getValue($entrypoint, 'basic_significant_urlengine_entrypoints', null, true)) {
$inifile->setValue($entrypoint, '1', 'basic_significant_urlengine_entrypoints', null, true);
}
$params = array();
$this->createFile(JELIX_APP_PATH . 'responses/adminHtmlResponse.class.php', 'responses/adminHtmlResponse.class.php.tpl', $params);
$this->createFile(JELIX_APP_PATH . 'responses/adminLoginHtmlResponse.class.php', 'responses/adminLoginHtmlResponse.class.php.tpl', $params);
$this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/auth.coord.ini.php', 'var/config/auth.coord.ini.php.tpl', $params);
$this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/jacl2.coord.ini.php', 'var/config/jacl2.coord.ini.php.tpl', $params);
$authini = new jIniFileModifier(JELIX_APP_CONFIG_PATH . $entrypoint . '/auth.coord.ini.php');
$authini->setValue('after_login', 'master_admin~default:index');
$authini->setValue('timeout', '30');
$profile = $this->getOption('-profile');
if (!$this->getOption('-noauthdb')) {
$authini->setValue('dao', 'jauth~jelixuser', 'Db');
$authini->setValue('form', 'jauthdb_admin~jelixuser', 'Db');
if ($profile != '') {
$authini->setValue('profile', $profile, 'Db');
}
$tools = jDb::getTools($profile);
$db = jDb::getConnection($profile);
$path = JELIX_LIB_PATH . 'core-modules/jelix/install/sql/';
if (file_exists($path . 'install_jauth.schema.' . $db->dbms . '.sql')) {
try {
$tools->execSQLScript($path . 'install_jauth.schema.' . $db->dbms . '.sql');
$rs = $db->query("SELECT usr_login FROM jlx_user WHERE usr_login='admin'");
if (!$rs || !$rs->fetch()) {
$db->exec("INSERT INTO jlx_user (usr_login , usr_password , usr_email) VALUES ('admin', '" . md5('admin') . "', 'admin@localhost.localdomain')");
}
$rs = null;
} catch (Exception $e) {
echo "An error has occured during the execution of SQL script to install jAuth: " . $e->getMessage() . "\n";
}
} else {
echo "Tables and datas for jAuth.db couldn't be created because SQL scripts are not available for the database declared in the profile.\nYou should initialize the database by hand.\n";
}
} else {
$inifile->setValue('unusedModules', $inifile->getValue('unusedModules') . ', jauthdb_admin');
}
if (!$this->getOption('-noacl2db')) {
$tools = jDb::getTools($profile);
//.........这里部分代码省略.........
示例3: _updateDatabase
/**
* private function to handle the database migration
*/
private function _updateDatabase()
{
//1) if the file installer.ini.php does not exist we cant install jelix nor havefnubb;
// then the application has not been installed with jelix 1.2
// so we copy the installer.ini.php build for the application havefnubb
//2) if the file exists, that means jelix 1.2 is "installed"
// so no need to try to install jelix
if (!file_exists(jApp::configPath() . 'installer.ini.php')) {
copy(dirname(__FILE__) . '/../../../install/installer.ini.php', jApp::configPath() . 'installer.ini.php');
}
jApp::loadConfig('havefnubb/config.ini.php');
//get the dbprofils file
$dbProfile = jIniFile::read(jApp::configPath() . jApp::config()->dbProfils);
//get the default profile
$tools = jDb::getTools($dbProfile['default']);
// migrate from 1.3.6 to 1.4.0
$tools->execSQLScript(dirname(__FILE__) . '/../../../sql/update_to_1.4.0.mysql.sql');
}
示例4: run
public function run()
{
jxs_init_jelix_env();
$path = $this->getModulePath($this->_parameters['module']);
$filename = $path . 'daos/';
$this->createDir($filename);
$filename .= strtolower($this->_parameters['name']) . '.dao.xml';
$profile = $this->getOption('-profile');
$param = array('name' => $this->_parameters['name'], 'table' => $this->getParam('table'));
if ($param['table'] == null) {
$param['table'] = $param['name'];
}
if ($this->getOption('-empty')) {
$this->createFile($filename, 'dao_empty.xml.tpl', $param);
} else {
$tools = jDb::getTools($profile);
$fields = $tools->getFieldList($param['table']);
$properties = '';
$primarykeys = '';
foreach ($fields as $fieldname => $prop) {
switch (strtolower($prop->type)) {
case 'clob':
case 'text':
case 'mediumtext':
case 'longtext':
case 'tinytext':
$type = 'text';
break;
case 'varchar2':
case 'varchar':
case 'char':
case 'enum':
case 'bpchar':
case 'set':
$type = 'string';
break;
case 'number':
case 'tinyint':
case 'numeric':
case 'int':
case 'integer':
case 'smallint':
case 'year':
if ($prop->autoIncrement) {
$type = 'autoincrement';
} else {
$type = 'int';
}
break;
case 'mediumint':
case 'bigint':
if ($prop->autoIncrement) {
$type = 'bigautoincrement';
} else {
$type = 'numeric';
}
break;
case 'float':
case 'double':
case 'decimal':
$type = 'float';
break;
case 'date':
$type = 'date';
break;
case 'timestamp':
case 'datetime':
$type = 'datetime';
break;
case 'time':
$type = 'time';
break;
case 'bool':
case 'boolean':
$type = 'boolean';
break;
default:
$type = '';
}
if ($type != '') {
$properties .= "\n <property name=\"{$fieldname}\" fieldname=\"{$fieldname}\"";
$properties .= ' datatype="' . $type . '"';
if ($prop->primary) {
if ($primarykeys != '') {
$primarykeys .= ',' . $fieldname;
} else {
$primarykeys .= $fieldname;
}
}
if ($prop->notNull && !$prop->autoIncrement) {
$properties .= ' required="true"';
}
if ($prop->hasDefault) {
$properties .= ' default="' . htmlspecialchars($prop->default) . '"';
}
if ($prop->length) {
$properties .= ' maxlength="' . $prop->length . '"';
}
if ($prop->sequence) {
$properties .= ' sequence="' . $prop->sequence . '"';
//.........这里部分代码省略.........