本文整理汇总了PHP中Record::logQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::logQuery方法的具体用法?PHP Record::logQuery怎么用?PHP Record::logQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::logQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeFrontendLayout
private function executeFrontendLayout()
{
$sql = 'SELECT content_type, content FROM ' . TABLE_PREFIX . 'layout WHERE name = ' . "'{$this->frontend_layout}'";
Record::logQuery($sql);
$stmt = Record::getConnection()->prepare($sql);
$stmt->execute();
$layout = $stmt->fetchObject();
if ($layout) {
// If content-type is not set, we set text/html by default.
if ($layout->content_type == '') {
$layout->content_type = 'text/html';
}
// Set content-type and charset of the page.
header('Content-Type: ' . $layout->content_type . '; charset=UTF-8');
// Provides compatibility with the Page class.
// @todo Find cleaner way of doing multiple inheritance
$this->url = CURRENT_PATH;
// Execute the layout code.
eval('?>' . $layout->content);
}
}
示例2: _restore
function _restore($fileData)
{
global $__CMS_CONN__;
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Wolf CMS core.
$tablenames = array();
if (strpos(DB_DSN, 'mysql') !== false) {
$sql = 'show tables';
}
if (strpos(DB_DSN, 'sqlite') !== false) {
$sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table" ORDER BY name';
}
if (strpos(DB_DSN, 'pgsql') !== false) {
$sql = "select tablename from pg_tables where schemaname='public'";
}
Record::logQuery($sql);
$pdo = Record::getConnection();
$result = $pdo->query($sql);
while ($col = $result->fetchColumn()) {
$tablenames[] = $col;
}
// All fields that should be wrapped as CDATA
$cdata_fields = array('title', 'content', 'content_html');
$xml = simplexml_load_string($fileData);
if (false === $xml) {
$errors = '';
foreach (libxml_get_errors() as $error) {
$errors .= $error->message;
$errors .= "<br/>\n";
}
Flash::set('error', 'An error occurred with the XML backup file: :error', array(':error' => $errors));
redirect(get_url('plugin/backup_restore'));
}
// Import each table and table entry
foreach ($tablenames as $tablename) {
$container = $tablename . 's';
if (array_key_exists($container, $xml) && count($xml->{$container}->{$tablename}) > 0) {
if (strpos(DB_DSN, 'sqlite') !== false) {
$sql = 'DELETE FROM ' . $tablename;
} else {
$sql = 'TRUNCATE ' . $tablename;
}
Record::logQuery($sql);
if (false === $__CMS_CONN__->exec($sql)) {
Flash::set('error', __('Unable to truncate current table :tablename.', array(':tablename' => $tablename)));
redirect(get_url('plugin/backup_restore'));
}
foreach ($xml->{$container}->{$tablename} as $element) {
$keys = array();
$values = array();
$delete_salt = false;
foreach ($element as $key => $value) {
$keys[] = $key;
if ($key === 'password' && empty($value)) {
$delete_salt = true;
if (isset($settings['default_pwd']) && $settings['default_pwd'] !== '') {
$value = sha1($settings['default_pwd']);
} else {
$value = sha1('pswpsw123');
}
$values[] = $__CMS_CONN__->quote($value);
} else {
$attributes = (array) $value->attributes();
$values[] = (isset($attributes['@attributes']) and $attributes['@attributes']['null']) ? 'NULL' : $__CMS_CONN__->quote($value);
}
}
if ($delete_salt and isset($keys['salt'])) {
unset($keys['salt']);
}
$sql = 'INSERT INTO ' . $tablename . ' (' . join(', ', $keys) . ') VALUES (' . join(', ', $values) . ')' . "\r";
if ($__CMS_CONN__->exec($sql) === false) {
Flash::set('error', __('Unable to reconstruct table :tablename.', array(':tablename' => $tablename)));
redirect(get_url('plugin/backup_restore'));
}
}
}
}
// Erase all uploaded files?
if ($settings['erasefiles'] == '1') {
$this->_cleanup_directory(realpath(FILES_DIR));
}
// Restore directories and files from XML
if ($settings['restorefiles'] == '1' && array_key_exists('files', $xml)) {
// First directories
foreach ($xml->files->directory as $obj) {
$name = realpath(FILES_DIR) . '/' . $obj->name;
if (!file_exists($name)) {
if (mkdir($name, 0777, true) === false) {
Flash::set('error', __('Unable to create directory :name.', array(':name' => dirname($obj->name))));
redirect(get_url('plugin/backup_restore'));
}
}
$this->_restore_attributes($name, $obj);
}
// Then files
foreach ($xml->files->file as $obj) {
$name = realpath(FILES_DIR) . '/' . $obj->name;
if (file_put_contents($name, base64_decode($obj->content)) === false) {
Flash::set('error', __('Unable to restore file :name.', array(':name' => $obj->name)));
redirect(get_url('plugin/backup_restore'));
//.........这里部分代码省略.........
示例3: findBySql
private static function findBySql($sql, $values = null)
{
$class_name = get_called_class();
Record::logQuery($sql);
// Prepare and execute
$stmt = Record::getConnection()->prepare($sql);
if (!$stmt->execute($values)) {
return false;
}
$page_class = 'Page';
$objects = array();
while ($page = $stmt->fetchObject('Page')) {
$parent = $page->parent();
if (!empty($parent->behavior_id)) {
// will return Page by default (if not found!)
$page_class = Behavior::loadPageHack($parent->behavior_id);
}
// create the object page
$page = new $page_class($page, $parent);
$page->part = self::get_parts($page->id);
$objects[] = $page;
}
return $objects;
}
示例4: archivesByDay
function archivesByDay($year = 'all')
{
$tablename = TABLE_PREFIX . 'page';
$pdo = Record::getConnection();
$out = array();
if ($year == 'all') {
$year = '';
}
$sql = "SELECT DISTINCT(DATE_FORMAT(created_on, '%Y/%m/%d')) FROM {$tablename} WHERE parent_id = :parent_id AND status_id != :status ORDER BY created_on DESC";
Record::logQuery($sql);
$stmt = $pdo->prepare($sql);
$stmt->execute(array(':parent_id' => $this->page->id, ':status' => Page::STATUS_HIDDEN));
while ($date = $stmt->fetchColumn()) {
$out[] = $date;
}
return $out;
}
示例5: getSetting
/**
* Returns the value for a specified setting.
* Returns false when unsuccessful in retrieving the setting.
*
* @param <type> $name
* @param <type> $plugin_id
*/
static function getSetting($name = null, $plugin_id = null)
{
if ($name == null || $plugin_id == null) {
return false;
}
$tablename = TABLE_PREFIX . 'plugin_settings';
$existingSettings = array();
$sql = "SELECT value FROM {$tablename} WHERE plugin_id=:pluginid AND name=:name LIMIT 1";
Record::logQuery($sql);
$stmt = Record::getConnection()->prepare($sql);
$stmt->execute(array(':pluginid' => $plugin_id, ':name' => $name));
return $stmt->fetchColumn();
}