/** * Обновляет информацию о шаблоне * * @param $tpl string имя шаблона * @param $szContent string содержимое шаблона * @param $szComment string комментарий к шаблону (в HTML-виде) */ public static function update($tpl, $szContent, $szComment) { self::checkPathCorrect($tpl); // $szPath = self::createTemplatePath($tpl); // Проверяем, что шаблон существует if (!file_exists($szPath)) { throw new SitemapTemplateException('Template `' . $tpl . '` not found'); } // Проверяем существование записи в базе $aDB = self::getFromDB($tpl); if (empty($aDB)) { $tpl = \Faid\DB::$connection->real_escape_string($tpl); $szComment = \Faid\DB::$connection->real_escape_string($szComment); // $sql = 'INSERT INTO `%s` SET `path`="%s",`comment`="%s"'; $sql = sprintf($sql, SITEMAP_TEMPLATE_TABLE, $tpl, $szComment); DB::post($sql); } else { $aDB['id']; // Сохраняем коммент $sql = 'UPDATE `%s` SET `comment`="%s" WHERE `id`="%d"'; $sql = sprintf($sql, SITEMAP_TEMPLATE_TABLE, $szComment, $aDB['id']); DB::post($sql); } // Сохраняем содержимое файла file_put_contents($szPath, $szContent); }
public static function post($sql, $bIgnore = false) { Trace::addMessage(__CLASS__, sprintf('Post:<br>%s', $sql)); $result = parent::post($sql, $bIgnore); Trace::addMessage(__CLASS__, sprintf('Post finished')); return $result; }
/** * Удаляет пользователя * @return */ public static function deleteUser($nUserId) { $nUserId = intval($nUserId); // $sql = 'DELETE FROM `%s` WHERE `id`="%d"'; $sql = sprintf($sql, CMS_AUTH_TABLE, $nUserId); return DB::post($sql); }
public function cleanup($period = 0) { if (!empty($period)) { DBSimple::delete(self::TableName, array(sprintf('`actionDate` <= NOW() - INTERVAL %s', $period))); } else { $sql = sprintf('truncate %s ', self::TableName); DB::post($sql); } }
public static function dbFixture($tableName, $data) { $sql = sprintf(' TRUNCATE `%s` ', $tableName); \Faid\DB::post($sql); // foreach ($data as $row) { \Faid\DBSimple::insert($tableName, $row); } }
/** * Обновляет запись об частоте */ public static function update($id, $priority, $change) { $sql = 'UPDATE `%s` SET `sitemap_xml_priority`="%f",`sitemap_xml_change`="%s" WHERE `id`="%d"'; $sql = sprintf($sql, SITEMAP_TABLE, floatval($priority), \Faid\DB::escape($change), intval($id)); DB::post($sql); $register = new SystemRegister('System/Sitemap/'); if ($register->get('sitemap.xml.disable')->value == 0) { self::generate(); } }
/** * * Дает доступ к определенному объекту для определннной сущности * @param string $path * @param string $entity */ public static function grant($path, $entity) { if (empty($entity)) { throw new ACLException('entity empty!'); } // Получаем элемент $el = self::get($path); // Добавляем в бд $sql = 'INSERT INTO `%s` SET `actionId`="%d",`entity`="%s" ON DUPLICATE KEY UPDATE `actionId`="%d" '; $sql = sprintf($sql, ACL_GRANT_TABLE, $el['id'], \Faid\DB::escape($entity), $el['id']); DB::post($sql); }
protected function createTable() { $sql = <<<SQL create table `test_document` ( \t`id` int not null auto_increment, \t`name` varchar(255 ) not null default '', \tprimary key (`id`) ); SQL; DB::post($sql); DBSimple::insert(Model::TableName, array('name' => 'sitemap document')); }
public function setUp() { parent::setUp(); self::dropTable(); $sql = <<<SQL \t\tCREATE TABLE `test_model` ( \t\t \tid int not null auto_increment, \t\t \tname varchar(255) not null, \t\t \tprimary key (`id` ) \t\t) SQL; DB::post($sql); DBSimple::insert('test_model', array('id' => 1, 'name' => self::fixtureName)); }
protected function loadConfigurationFile() { try { $sql = sprintf('truncate %s ', Job::TableName); DB::post($sql); $path = \Faid\Configure\Configure::read(self::ConfigureKey); $validator = new ReadableFile($path); if ($validator->isValid()) { include $path; } \CMSLog::addMessage(__CLASS__, 'Schedule restarted'); } catch (\Exception $e) { \CMSLog::addMessage(__CLASS__, $e); return ['error' => 'internal error']; } return; }
/** * Создает новую схему * @param string $schemaName имя схемы * @return CConfigSchema $schemaName */ public static function createSchema($schemaName) { if (empty($schemaName)) { throw new CConfigException('Empty schemaName'); } // Проверяем, что такая схема существует $exists = self::checkSchemaExists($schemaName); if ($exists) { throw new CConfigException('Duplicate schema'); } // Запрос на создание схемы $sql = 'INSERT INTO `%s` SET `name`="%s"'; $sql = sprintf($sql, CCONFIG_SCHEMA_TABLE, \Faid\DB::escape($schemaName)); DB::post($sql); $id = DB::$connection->insert_id; // Получаем объект схемы $result = new CConfigSchema(array('id' => $id, 'name' => $schemaName)); return $result; }
public function createDatabaseTable($dropTable = false) { parent::createDatabaseTable($dropTable); $sql = sprintf('alter table %s add index `login_status` (`user_id`, `status`)', self::TableName); DB::post($sql); }
protected static function cleanDB() { $sql = sprintf(' delete from %s where `date` < "%s"', self::TableName, date('Y-m-d H:i:s', strtotime('-' . self::$config['Period']))); DB::post($sql); }
/** * ------------------------------------------------------------------------------------------- * Сохраняет результат работы метода exec * @return * ------------------------------------------------------------------------------------------- */ public static function storeRows() { $sqlTemplate = 'UPDATE `%s` SET `full_url`="%s" where `id`="%d"'; foreach (self::$aResult as $nId => $szFullUrl) { $sql = sprintf($sqlTemplate, SITEMAP_TABLE, \Faid\DB::escape($szFullUrl), intval($nId)); DB::post($sql); } }
public function delete() { $sql = 'delete from `%s` where `id`="%d"'; $sql = sprintf($sql, CCONFIG_CONTROL_TABLE, $this->id); DB::post($sql); }
public static function createTables() { $sql = <<<SQL \tcreate table %s ( \t\t`id` int not null auto_increment, \t\t`user_id` int not null default 0, \t\t`network_id` int not null default 0, \t\t`uid` varchar(255) not null default '', \t\t`date` datetime not null default '0000-00-00 00:00:00', \t\tprimary key ( `id` ), \t\tindex `search_by_user` ( `user_id` ) \t) SQL; $sql = sprintf($sql, self::UIDTable); DB::post($sql); }
/** * @author Midgard * @desc Функция импортирует строку с запросами MySQL в базу. * @param $sql_query Строка запросов. */ function import($sql_query) { if (!empty($sql_query)) { $pieces = array(); $this->__splitSqlFile($pieces, $sql_query); foreach ($pieces as $value) { DB::post($value); } } }
/** * Удаляет все записи из лога */ public static function deleteAll() { // Пока что достаточно полной очистки базы DB::post('TRUNCATE `' . self::TableName . '`'); }
public function onCreateTable(\Extasy\ORM\QueryBuilder $queryBuilder) { $sql = <<<SQL create table %s ( `id` int not null auto_increment, `%s` int not null default 0, `%s` int not null default 0, primary key (`id`), index `search` (`%s`) ) SQL; $sql = sprintf($sql, $this->innerKey, $this->foreighnKey, $this->innerKey); DB::post($sql); }
<?php use Faid\DB; use Faid\DBSimple; use Extasy\Audit\Record; use Extasy\Audit\Log; DB::post('TRUNCATE audit_logs'); DB::post('TRUNCATE audit_records'); // $sql = 'select distinct category from cms_log order by category asc'; $data = DB::query($sql); foreach ($data as $row) { $log = createLog($row); importMessages($log, $row['category']); } function createLog($row) { $log = new Log(); $log->name = 'Developer.' . $row['category']; $log->enable_logging = true; if (CMSLog::RuntimeErrors == $row['category']) { $log->critical = true; } $log->insert(); return $log; } function importMessages($log, $category) { $data = selectMessages($category); foreach ($data as $record) { Record::add($log->name, $record['message'], $record['message']);
public static function updateParentCount($nId) { if ($nId == 0) { return; } $nId = intval($nId); $nCount = Sitemap_Sample::getCount($nId); // $sql = 'UPDATE `%s` SET `count`=%d WHERE `id`="%d"'; $sql = sprintf($sql, SITEMAP_TABLE, $nCount, $nId); DB::post($sql); }
use Extasy\CMS; use Faid\DB; use Faid\Dispatcher\Dispatcher; use Faid\Request\Request; require_once '../Vendors/Extasy/src/bootstrap.php'; $request = new Request(); $dispatcher = new Dispatcher($request); new CMS($dispatcher); set_time_limit(0); $nLevel = !empty($_GET['level']) ? $_GET['level'] : die('Setup level!'); require_once LIB_PATH . 'kernel/cms/cms.php'; require_once LIB_PATH . 'sitemap/additional/project_helper.php'; switch ($nLevel) { case '1': DB::post('TRUNCATE `' . SITEMAP_TABLE . '`'); DB::post('TRUNCATE `' . SITEMAP_SCRIPT_CHILD_TABLE . '`'); break; case '-999': // Это блок для копипаста // Главная баннеры //Sitemap::addScript('Главная','scripts/index.php','',0,'index/page.php',1); //SiteMap::setupScriptChildDocuments('scripts/go-child.php',array('textpage')); //$sql = <<<EOD // ALTER TABLE `textpage` // ADD COLUMN `text_class` varchar(255) not null, // ADD COLUMN `background_class` varchar(255) not null, // ADD COLUMN `hover_class` varchar(255) not null; //EOD; //DB::post($sql); //EventController::addEvent('get_portfolio_template_data'); //EventController::addEventListener('get_portfolio_template_data','selectSizes','PortfolioTemplate','_lib/portfolio.php');
public function setUp() { DB::post('truncate table test_model'); DBSimple::insert('test_model', array('id' => 1, 'name' => self::fixtureName)); }
/** * Сохраняет в бд данные */ protected function store() { // Сохраняем вкладки $sql = 'update `%s` set `name`="%s",`title`="%s",`sitemapId`="%d" where `id`="%d"'; $sql = sprintf($sql, CCONFIG_SCHEMA_TABLE, \Faid\DB::escape($this->name), \Faid\DB::escape($this->title), \Faid\DB::escape($this->sitemapId), $this->id); DB::post($sql); }
<?php use Faid\DB; $sql = <<<SQL \tcreate table schedule_job ( \t\t`id` int not null auto_increment, \t\t`status` int not null default 0, \t\t`action` varchar(255) not null default '', \t\t`class` varchar(255) not null default '', \t\t`dateCreated` datetime not null default "0000-00-00 00:00:00", \t\t`actionDate` datetime not null default "0000-00-00 00:00:00", \t\t`repeatable` int not null default 0, \t\t`period` int not null default 0, \t\t`data` blob null, \t\tprimary key (`id`), \t\tindex status (`status`) \t) SQL; DB::post($sql);
public static function deleteAlias($id, $url) { $id = IntegerHelper::toNatural($id); $sql = 'DELETE FROM `%s` WHERE `page_id`="%d" and `url`="%s" '; $sql = sprintf($sql, SITEMAP_HISTORY_TABLE, $id, \Faid\DB::escape($url)); DB::post($sql); }
/** * Обновляет лист в бд */ public static function update(SystemRegister $parent, $id, $szName, $szValue, $szComment, $szType) { // Экранируем переменные $id = intval($id); $szName = \Faid\DB::escape($szName); $szValue = \Faid\DB::escape($szValue); $szComment = \Faid\DB::escape($szComment); $szType = \Faid\DB::escape($szType); // запрос $sql = 'UPDATE `%s` SET `name`="%s",`value`="%s",`comment`="%s",`type`="%s" WHERE `id`="%s"'; $sql = sprintf($sql, SYSTEMREGISTER_TABLE, $szName, $szValue, $szComment, $szType, $id); // DB::post($sql); // обновляем кеш предка self::updateChildCache($parent->getId()); self::updateGetCache($szName, $parent->getId()); return $id; }
/** * Обновляет данные о видимости страницы * @param int $sitemapId * @todo Перенести sql-запрос в отдельный класс */ protected static function updateVisible($sitemapId) { if (!empty($_POST['sitemap_visible'])) { $visible = 1; } else { $visible = 0; } $sql = 'UPDATE `sitemap` SET `visible`="%d" WHERE `id`="%d"'; $sql = sprintf($sql, $visible, $sitemapId); DB::post($sql); }