本文整理汇总了PHP中IPSSetUp::addPrefixToQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP IPSSetUp::addPrefixToQuery方法的具体用法?PHP IPSSetUp::addPrefixToQuery怎么用?PHP IPSSetUp::addPrefixToQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPSSetUp
的用法示例。
在下文中一共展示了IPSSetUp::addPrefixToQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @access public
* @return void
*/
public function __construct(ipsRegistry $registry)
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Make sure tables exist that won't in pre 3.0 versions */
if (file_exists(IPS_ROOT_PATH . 'setup/sql/ipb3_' . strtolower(ipsRegistry::$settings['sql_driver']) . '.php')) {
require IPS_ROOT_PATH . 'setup/sql/ipb3_' . strtolower(ipsRegistry::$settings['sql_driver']) . '.php';
$prefix = $this->registry->dbFunctions()->getPrefix();
if (!$this->DB->checkForField('upgrade_app', 'upgrade_history')) {
if ($UPGRADE_TABLE_FIELD) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_TABLE_FIELD, $prefix));
}
}
if (!$this->DB->checkForTable('upgrade_sessions')) {
if ($UPGRADE_SESSION_TABLE) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_SESSION_TABLE, $prefix));
}
}
}
}
示例2: __construct
/**
* Constructor
*
* @access public
* @return @e void
*/
public function __construct(ipsRegistry $registry)
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
//* Make sure tables exist that won't in pre 3.0 versions */
if (is_file(IPS_ROOT_PATH . 'setup/sql/ipb3_' . strtolower(ipsRegistry::$settings['sql_driver']) . '.php')) {
/* Init vars */
$UPGRADE_HISTORY_TABLE = '';
$UPGRADE_TABLE_FIELD = '';
$UPGRADE_SESSION_TABLE = '';
$UPGRADE_CSS_PREVIOUS = '';
$UPGRADE_TEMPLATE_PREVIOUS = '';
require IPS_ROOT_PATH . 'setup/sql/ipb3_' . strtolower(ipsRegistry::$settings['sql_driver']) . '.php';
/*noLibHook*/
$prefix = $this->registry->dbFunctions()->getPrefix();
if (!$this->DB->checkForTable('upgrade_history')) {
if ($UPGRADE_HISTORY_TABLE) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_HISTORY_TABLE, $prefix));
}
}
if (!$this->DB->checkForField('upgrade_app', 'upgrade_history')) {
if ($UPGRADE_TABLE_FIELD) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_TABLE_FIELD, $prefix));
}
}
if (!$this->DB->checkForTable('upgrade_sessions')) {
if ($UPGRADE_SESSION_TABLE) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_SESSION_TABLE, $prefix));
}
}
if (!$this->DB->checkForTable('skin_css_previous')) {
if ($UPGRADE_CSS_PREVIOUS) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_CSS_PREVIOUS, $prefix));
}
}
if (!$this->DB->checkForTable('skin_templates_previous')) {
if ($UPGRADE_TEMPLATE_PREVIOUS) {
$this->DB->query(IPSSetUp::addPrefixToQuery($UPGRADE_TEMPLATE_PREVIOUS, $prefix));
}
}
}
}
示例3: upgradeSql
/**
* Run SQL files
*
* @param int
* @return @e void
*/
public function upgradeSql($id = 1)
{
$cnt = 0;
$SQL = array();
$file = '_updates_' . $id . '.php';
$output = "";
$path = IPSLib::getAppDir('core') . '/setup/versions/upg_30001/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
$prefix = $this->registry->dbFunctions()->getPrefix();
$sourceFile = '';
if (is_file($path)) {
require $path;
/*noLibHook*/
/* Set DB driver to return any errors */
$this->DB->return_die = 1;
foreach ($SQL as $query) {
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
$query = str_replace("<%time%>", time(), $query);
if ($this->settings['mysql_tbl_type']) {
if (preg_match("/^create table(.+?)/i", $query)) {
$query = preg_replace("/^(.+?)\\);\$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query);
}
}
/* Need to tack on a prefix? */
if ($prefix) {
$query = IPSSetUp::addPrefixToQuery($query, $prefix);
}
if (IPSSetUp::getSavedData('man')) {
$query = trim($query);
/* Ensure the last character is a semi-colon */
if (substr($query, -1) != ';') {
$query .= ';';
}
$output .= $query . "\n\n";
} else {
$this->DB->query($query);
if ($this->DB->error) {
$this->registry->output->addError("<br />" . $query . "<br />" . $this->DB->error);
} else {
$cnt++;
}
}
}
$this->registry->output->addMessage("{$cnt} запросов выполнено....");
}
/* Next Page */
$this->request['st'] = 0;
if ($id < 6) {
$nextid = $id + 1;
$this->request['workact'] = 'sql' . $nextid;
} else {
$this->request['workact'] = 'applications';
}
if (IPSSetUp::getSavedData('man') and $output) {
/* Create source file */
if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
$sourceFile = IPSSetUp::createSqlSourceFile($output, '30001', $id);
}
$this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
}
}
示例4: upgradeLogs
/**
* Upgrade log file tables
*
* @param int
* @return @e void
*/
public function upgradeLogs($id = 1)
{
/* Verify posts alter table query has run */
if ($id == 1) {
if (!$this->DB->checkForField('post_bwoptions', 'posts')) {
$this->_output = ' ';
$this->registry->output->addError("Вы должны выполнить запрос изменяющий таблицу posts. После того как вы выполните это, просто обновите данную страницу и обновление будет продолжено.");
return;
}
}
$cnt = 0;
$file = '_updates_logs_' . $id . '.php';
$output = "";
$path = IPSLib::getAppDir('core') . '/setup/versions/upg_32000/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
$prefix = $this->registry->dbFunctions()->getPrefix();
if (is_file($path)) {
$SQL = array();
$TABLE = '';
require $path;
/*noLibHook*/
/* Set DB driver to return any errors */
$this->DB->return_die = 1;
foreach ($SQL as $query) {
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
/* Need to tack on a prefix? */
if ($prefix) {
$query = IPSSetUp::addPrefixToQuery($query, $prefix);
}
/* Chose to prune and run? */
if ($this->request['pruneAndRun']) {
$this->DB->delete($TABLE);
$man = false;
} else {
/* Show alter table / prune option? */
$man = IPSSetUp::getSavedData('man');
if ($TABLE) {
$count = $this->DB->buildAndFetch(array('select' => 'count(*) as logs', 'from' => $TABLE));
if ($count['logs'] > 100000) {
$man = true;
}
}
}
/* Show option to run manually or prune ? */
if ($man) {
$query = trim($query);
/* Ensure the last character is a semi-colon */
if (substr($query, -1) != ';') {
$query .= ';';
}
$output .= $query . "\n\n";
} else {
$this->DB->query($query);
if ($this->DB->error) {
$this->registry->output->addError("<br />" . $query . "<br />" . $this->DB->error);
} else {
$cnt++;
}
}
}
$this->registry->output->addMessage("{$cnt} запросов выполнено....");
}
/* Next Page */
if ($id < 10) {
$nextid = $id + 1;
$this->request['workact'] = 'logs' . $nextid;
} else {
$this->request['workact'] = 'forums';
}
if ($output) {
$this->_output = $this->registry->output->template()->upgrade_manual_queries_logs($output, $id, $TABLE);
}
}
示例5: upgrade_sql
function upgrade_sql($id = 1)
{
$man = 0;
// Manual upgrade ? intval( $this->request['man'] );
$cnt = 0;
$SQL = array();
$file = '_updates_' . $id . '.php';
$output = "";
$path = IPSLib::getAppDir('core') . '/setup/versions/upg_21003/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
$prefix = $this->registry->dbFunctions()->getPrefix();
if (is_file($path)) {
require $path;
/*noLibHook*/
$this->error = array();
$this->sqlcount = 0;
$output = "";
$this->DB->return_die = 1;
foreach ($SQL as $query) {
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
$query = str_replace("<%time%>", time(), $query);
/* Need to tack on a prefix? */
if ($prefix) {
$query = IPSSetUp::addPrefixToQuery($query, $prefix);
}
if (IPSSetUp::getSavedData('man')) {
$output .= preg_replace("/\\s{1,}/", " ", $query) . "\n\n";
} else {
if (!$query) {
continue;
}
$this->DB->query($query);
if ($this->DB->error) {
$this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
} else {
$this->sqlcount++;
}
}
}
$this->registry->output->addMessage("{$this->sqlcount} queries ran....");
}
//--------------------------------
// Next page...
//--------------------------------
$this->request['st'] = 0;
if ($id != 4) {
$nextid = $id + 1;
$this->request['workact'] = 'sql' . $nextid;
} else {
$this->request['workact'] = 'polls';
}
if (IPSSetUp::getSavedData('man') and $output) {
/* Create source file */
if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
$sourceFile = IPSSetUp::createSqlSourceFile($output, '21003', $id);
}
$this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
}
}
示例6: install_sql
/**
* Installs SQL schematic
*
* @return void
*/
public function install_sql()
{
/* Lets grab that SQL! */
$SQL = array();
$count = 0;
$output = '';
$message = array();
$sourceFile = '';
$warnings = 0;
/* Reset Errors */
$this->_resetErrors();
/* SQL */
$file = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/' . $this->_dbDriver . '_updates.php';
/* Get file */
if (is_file($file)) {
require $file;
/*noLibHook*/
if (is_array($SQL) and count($SQL) > 0) {
/* Loop */
foreach ($SQL as $q) {
/* Set DB driver to return any errors */
$this->DB->return_die = 1;
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
$q = str_replace("<%time%>", time(), $q);
$q = IPSSetUp::addPrefixToQuery($q, $this->registry->dbFunctions()->getPrefix());
if ($this->settings['mysql_tbl_type']) {
if (preg_match("/^create table(.+?)/i", $q)) {
$q = preg_replace("/^(.+?)\\);\$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $q);
}
}
if (IPSSetUp::getSavedData('man')) {
$q = trim($q);
/* Ensure the last character is a semi-colon */
if (substr($q, -1) != ';') {
$q .= ';';
}
$output .= $q . "\n\n";
} else {
$this->DB->query($q);
if ($this->DB->error) {
/* Log but do not fail on certain error logs */
$msg = $this->DB->error;
if (preg_match("#table.*already exists#i", $msg) or preg_match("#Duplicate column name#i", $msg) or preg_match("#Duplicate entry.*for#i", $msg)) {
$warnings++;
IPSSetUp::addLogMessage("SQL Error: " . $q . "\n" . $msg, $this->_uipLong, $this->_currentApp);
} else {
$this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error);
}
} else {
$count++;
}
}
}
$message[] = $count . " запросов выполнено ({$warnings} не критичных ошибок)";
}
} else {
/* No SQL */
//$this->registry->output->addMessage("Нет SQL запросов для выполнения.");
$this->install_appclass();
return;
}
/* Got queries to show? */
if (IPSSetUp::getSavedData('man') and $output) {
/* Create source file */
if ($this->_dbDriver == 'mysql') {
$sourceFile = IPSSetUp::createSqlSourceFile($output, $this->_uipLong);
}
$this->registry->output->setTitle("Обновление: База Данных");
$this->registry->output->setNextAction('upgrade&do=appclass');
$this->registry->output->addContent($this->registry->output->template()->upgrade_manual_queries($output, $sourceFile));
$this->registry->output->sendOutput();
} else {
//-----------------------------------------
// Next...
//-----------------------------------------
$output = (is_array($message) and count($message)) ? $message : array(0 => "Обновление Базы Данных завершено");
$this->_finishStep($output, "Обновление: База Данных", 'upgrade&do=appclass');
}
}
示例7: upgrade_sql
function upgrade_sql($id = 1)
{
$man = 0;
// Manual upgrade ? intval( $this->install->ipsclass->input['man'] );
$cnt = 0;
$SQL = array();
$file = '_updates_' . $id . '.php';
$output = "";
$path = IPSLib::getAppDir('core') . '/setup/versions/upg_22005/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
$prefix = $this->registry->dbFunctions()->getPrefix();
if (file_exists($path)) {
require_once $path;
$this->sqlcount = 0;
$output = "";
$this->DB->return_die = 1;
foreach ($SQL as $query) {
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
$query = str_replace("<%time%>", time(), $query);
if ($this->settings['mysql_tbl_type']) {
if (preg_match("/^create table(.+?)/i", $query)) {
$query = preg_replace("/^(.+?)\\);\$/is", "\\1) TYPE={$this->settings['mysql_tbl_type']};", $query);
}
}
/* Need to tack on a prefix? */
if ($prefix) {
$query = IPSSetUp::addPrefixToQuery($query, $prefix);
}
if (IPSSetUp::getSavedData('man')) {
$output .= preg_replace("/\\s{1,}/", " ", $query) . "\n\n";
} else {
$this->DB->query($query);
if ($this->DB->error) {
$this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
} else {
$this->sqlcount++;
}
}
}
$this->registry->output->addMessage("{$this->sqlcount} queries run....");
}
//--------------------------------
// Next page...
//--------------------------------
$this->request['st'] = 0;
if ($id != 4) {
$nextid = $id + 1;
$this->request['workact'] = 'sql' . $nextid;
} else {
$this->request['workact'] = 'forums';
}
if (IPSSetUp::getSavedData('man') and $output) {
$this->_output = $this->registry->output->template()->upgrade_manual_queries($output);
}
}
示例8: updatePostsTable
/**
* Fix posts table
*
* @param int
* @return @e void
*/
public function updatePostsTable()
{
$doManual = $options['core'][33000]['manualPostsTableQuery'];
$prefix = $this->registry->dbFunctions()->getPrefix();
$output = '';
if ($doManual && !$this->DB->checkForField('post_field_int', 'posts')) {
foreach (array('ALTER TABLE posts ADD post_field_int INT(10) DEFAULT 0', 'ALTER TABLE posts ADD post_field_t1 TEXT NULL DEFAULT NULL', 'ALTER TABLE posts ADD post_field_t2 TEXT NULL DEFAULT NULL') as $query) {
$query = trim($query);
/* Need to tack on a prefix? */
if ($prefix) {
$query = IPSSetUp::addPrefixToQuery($query, $prefix);
}
/* Ensure the last character is a semi-colon */
if (substr($query, -1) != ';') {
$query .= ';';
}
$output .= $query . "\n\n";
}
} else {
if (!$this->DB->checkForField('post_field_int', 'posts')) {
$this->DB->addField('posts', 'post_field_int', 'INT(10)', '0');
}
if (!$this->DB->checkForField('post_field_t1', 'posts')) {
$this->DB->addField('posts', 'post_field_t1', 'TEXT');
}
if (!$this->DB->checkForField('post_field_t2', 'posts')) {
$this->DB->addField('posts', 'post_field_t2', 'TEXT');
}
}
if ($output) {
/* Create source file */
if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
$sourceFile = IPSSetUp::createSqlSourceFile($output, '33000', 'posts');
}
$this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
}
$this->registry->output->addMessage("Posts table updated");
$this->request['workact'] = 'ban';
}
示例9: install_sql
/**
* Installs SQL schematic
*
* @return void
*/
public function install_sql()
{
/* Lets grab that SQL! */
$SQL = array();
$cnt = 0;
$output = '';
$message = array();
$sourceFile = '';
/* Reset Errors */
$this->_resetErrors();
/* SQL */
$file = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/' . $this->_dbDriver . '_updates.php';
/* Get file */
if (file_exists($file)) {
require $file;
if (is_array($SQL) and count($SQL) > 0) {
/* Loop */
foreach ($SQL as $q) {
/* Set DB driver to return any errors */
$this->DB->return_die = 1;
$this->DB->allow_sub_select = 1;
$this->DB->error = '';
$q = str_replace("<%time%>", time(), $q);
$q = IPSSetUp::addPrefixToQuery($q, $this->registry->dbFunctions()->getPrefix());
if ($this->settings['mysql_tbl_type']) {
if (preg_match("/^create table(.+?)/i", $q)) {
$q = preg_replace("/^(.+?)\\);\$/is", "\\1) TYPE={$this->settings['mysql_tbl_type']};", $q);
}
}
if (IPSSetUp::getSavedData('man')) {
$q = trim($q);
/* Ensure the last character is a semi-colon */
if (substr($q, -1) != ';') {
$q .= ';';
}
$output .= $q . "\n\n";
} else {
$this->DB->query($q);
if ($this->DB->error) {
$this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error);
} else {
$count++;
}
}
}
$message[] = $count . " queries run...";
}
} else {
/* No SQL */
$this->registry->output->addMessage("No native SQL to run....");
$this->install_appclass();
return;
}
/* Got queries to show? */
if (IPSSetUp::getSavedData('man') and $output) {
/* Create source file */
if ($this->_dbDriver == 'mysql') {
$sourceFile = IPSSetUp::createSqlSourceFile($output, $this->_uipLong);
}
$this->registry->output->setTitle("Upgrade: SQL");
$this->registry->output->setNextAction('upgrade&do=appclass');
$this->registry->output->addContent($this->registry->output->template()->upgrade_manual_queries($output, $sourceFile));
$this->registry->output->sendOutput();
} else {
//-----------------------------------------
// Next...
//-----------------------------------------
$output = (is_array($message) and count($message)) ? $message : array(0 => "SQL complete");
$this->_finishStep($output, "Upgrade: SQL", 'upgrade&do=appclass');
}
}