本文整理汇总了PHP中Record::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::connection方法的具体用法?PHP Record::connection怎么用?PHP Record::connection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::connection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setMySQL
public function setMySQL()
{
$mysqli = DBMySQLi::getInstance();
if (!$mysqli->dbh) {
$this->error('系统繁忙,请稍候再试', '/index.php');
}
Record::connection($mysqli);
}
示例2: CKEditorGetConfigs
function CKEditorGetConfigs($key = null)
{
$tablename = TABLE_PREFIX . 'plugin_settings';
try {
$PDO = new PDO(DB_DSN, DB_USER, DB_PASS);
if ($PDO->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
$PDO->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
} catch (PDOException $error) {
try {
require_once substrtruncate($_SERVER['SCRIPT_FILENAME'], '/plugins') . '/libraries/DoLite.php';
$PDO = new DoLite(DB_DSN, DB_USER, DB_PASS);
} catch (PDOException $error) {
die('DB Connection failed: ' . $error->getMessage());
}
}
Record::connection($PDO);
$PDO = Record::getConnection();
$PDO->exec("set names 'utf8'");
$sql = "SELECT name,value FROM {$tablename} WHERE plugin_id='ckeditor'";
$settings = array();
$stmt = $PDO->prepare($sql);
$stmt->execute();
while ($obj = $stmt->fetchObject()) {
$settings[$obj->name] = $obj->value;
}
// language setting
/**/
AuthUser::load();
$settings['editorLanguage'] = AuthUser::getRecord()->language;
/**/
if ($settings) {
if ($key && in_array($key, $settings)) {
return $settings[$key];
} else {
// return all
return $settings;
}
}
return false;
}
示例3: mysql_function_date_format
if ($driver === 'mysql') {
$__CMS_CONN__->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
if ($driver === 'sqlite') {
// Adding date_format function to SQLite 3 'mysql date_format function'
if (!function_exists('mysql_date_format_function')) {
function mysql_function_date_format($date, $format)
{
return strftime($format, strtotime($date));
}
}
$__CMS_CONN__->sqliteCreateFunction('date_format', 'mysql_function_date_format', 2);
}
// DEFINED ONLY FOR BACKWARDS SUPPORT - to be taken out before 0.9.0
$__FROG_CONN__ = $__CMS_CONN__;
Record::connection($__CMS_CONN__);
Record::getConnection()->exec("set names 'utf8'");
Setting::init();
use_helper('I18n');
AuthUser::load();
if (AuthUser::isLoggedIn()) {
I18n::setLocale(AuthUser::getRecord()->language);
} else {
I18n::setLocale(Setting::get('language'));
}
// Only add the cron web bug when necessary
if (defined('USE_POORMANSCRON') && USE_POORMANSCRON && defined('POORMANSCRON_INTERVAL')) {
Observer::observe('page_before_execute_layout', 'run_cron');
function run_cron()
{
$cron = Cron::findByIdFrom('Cron', '1');
示例4: define
define('REMEMBER_LOGIN_LIFETIME', 1209600);
// two weeks
define('DEFAULT_CONTROLLER', 'page');
define('DEFAULT_ACTION', 'index');
define('COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIE_SECURE', false);
// Init ---------------------------------------------------------------------
include FROG_ROOT . '/config.php';
define('BASE_URL', URL_PUBLIC . ADMIN_DIR . (USE_MOD_REWRITE ? '/' : '/?/'));
include CORE_ROOT . '/Framework.php';
// database connection
if (USE_PDO) {
$__FROG_CONN__ = new PDO(DB_DSN, DB_USER, DB_PASS);
if ($__FROG_CONN__->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
$__FROG_CONN__->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
} else {
require_once CORE_ROOT . '/libraries/DoLite.php';
$__FROG_CONN__ = new DoLite(DB_DSN, DB_USER, DB_PASS);
}
Record::connection($__FROG_CONN__);
Record::getConnection()->exec("set names 'utf8'");
// Initialize settings
Setting::init();
use_helper('I18n');
I18n::setLocale(Setting::get('language'));
// Initialize Plugin
Plugin::init();
// Get controller and action and execute...
Dispatcher::dispatch();
示例5: backup
function backup()
{
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Fresh CMS core.
$tablenames = array('layout', 'page', 'page_part', 'page_tag', 'permission', 'plugin_settings', 'setting', 'snippet', 'tag', 'user', 'user_permission');
// All fields that should be wrapped as CDATA
$cdata_fields = array('content', 'content_html');
// Setup XML for backup
$xmltext = '<?xml version="1.0" encoding="UTF-8"?><freshcms></freshcms>';
$xmlobj = new SimpleXMLExtended($xmltext);
$xmlobj->addAttribute('version', CMS_VERSION);
// Retrieve all database information for placement in XML backup
global $__CMS_CONN__;
Record::connection($__CMS_CONN__);
$lasttable = '';
// Generate XML file entry for each table
foreach ($tablenames as $tablename) {
$table = Record::query('SELECT * FROM ' . TABLE_PREFIX . $tablename);
while ($entry = $table->fetchObject()) {
if ($lasttable !== $tablename) {
$lasttable = $tablename;
$child = $xmlobj->addChild($tablename . 's');
}
$subchild = $child->addChild($tablename);
while (list($key, $value) = each($entry)) {
if ($key === 'password' && $settings['pwd'] === '0') {
$value = '';
}
if (in_array($key, $cdata_fields, true)) {
$subchild->addCData($key, $value);
} else {
$subchild->addChild($key, $value);
}
}
}
}
// Create the XML file
$file = $xmlobj->asXML();
$filename = 'freshcms-backup-' . date($settings['stamp']);
// Offer a plain XML file or a zip file for download
if ($settings['zip'] == '1') {
// Create a note file
$note = "---[ NOTES for {$filename}.xml ]---\n\n";
$note .= "This backup was created for a specific Fresh CMS version, please only restore it\n";
$note .= "on the same version.\n\n";
$note .= "When restoring a backup, upload the UNzipped XML file, not this zip file.\n\n";
$note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
$note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
$note .= 'Created for Fresh CMS version ' . CMS_VERSION . "\n\n";
$note .= '---[ END NOTES ]---';
use_helper('Zip');
$zip = new Zip();
$zip->clear();
$zip->addFile($note, 'readme.txt');
$zip->addFile($file, $filename . '.xml');
$zip->download($filename . '.zip');
} else {
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: text/xml; charset=UTF-8');
header('Content-Disposition: attachment; filename=' . $filename . '.xml;');
header('Content-Transfer-Encoding: 8bit');
header('Content-Length: ' . strlen($file));
echo $file;
}
}
示例6: backup
function backup()
{
$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');
// Setup XML for backup
$xmltext = '<?xml version="1.0" encoding="UTF-8"?><wolfcms></wolfcms>';
$xmlobj = new SimpleXMLExtended($xmltext);
$xmlobj->addAttribute('version', CMS_VERSION);
// Retrieve all database information for placement in XML backup
global $__CMS_CONN__;
Record::connection($__CMS_CONN__);
// Generate XML file entry for each table
foreach ($tablenames as $tablename) {
$table = Record::query('SELECT * FROM ' . $tablename);
$child = $xmlobj->addChild($tablename . 's');
while ($entry = $table->fetch(PDO::FETCH_ASSOC)) {
$subchild = $child->addChild($tablename);
foreach ($entry as $key => $value) {
if ($key == 'password' && $settings['pwd'] === '0') {
$value = '';
}
if (in_array($key, $cdata_fields, true)) {
$valueChild = $subchild->addCData($key, $value);
} else {
$valueChild = $subchild->addChild($key, str_replace('&', '&', $value));
}
if ($value === null) {
$valueChild->addAttribute('null', true);
}
}
}
}
// Add XML files entries for all files in upload directory
if ($settings['backupfiles'] == '1') {
$dir = realpath(FILES_DIR);
$this->_backup_directory($xmlobj->addChild('files'), $dir, $dir);
}
// Create the XML file
$file = $xmlobj->asXML();
$filename = 'wolfcms-backup-' . date($settings['stamp']) . '.' . $settings['extension'];
// Offer a plain XML file or a zip file for download
if ($settings['zip'] == '1') {
// Create a note file
$note = "---[ NOTES for {$filename} ]---\n\n";
$note .= "This backup was created for a specific Wolf CMS version, please only restore it\n";
$note .= "on the same version.\n\n";
$note .= "When restoring a backup, upload the UNzipped XML backup file, not this zip file.\n\n";
$note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
$note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
$note .= 'Created for Wolf CMS version ' . CMS_VERSION . "\n\n";
$note .= '---[ END NOTES ]---';
use_helper('Zip');
$zip = new Zip();
$zip->clear();
$zip->addFile($note, 'readme.txt');
$zip->addFile($file, $filename);
$zip->download($filename . '.zip');
} else {
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: text/xml; charset=UTF-8');
header('Content-Disposition: attachment; filename=' . $filename . ';');
header('Content-Transfer-Encoding: 8bit');
header('Content-Length: ' . strlen($file));
echo $file;
}
}
示例7: array
$image_list_dir = '';
$image_public_path = 'undefined';
$preview_css = '';
$listhidden = 0;
$settings = array();
// Setup DB connection
try {
$PDO = new PDO(DB_DSN, DB_USER, DB_PASS);
} catch (PDOException $error) {
die('TinyMCE plugin - DB connection failed: ' . $error->getMessage());
}
if ($PDO->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
$PDO->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
// Get a DB connection
Record::connection($PDO);
$PDO = Record::getConnection();
$PDO->exec("set names 'utf8'");
// Query the DB for the plugin settings.
$sql = "SELECT name,value FROM {$tablename} WHERE plugin_id='tinymce'";
$stmt = $PDO->prepare($sql);
$stmt->execute();
// Build settings array with tinymce plugin settings
while ($obj = $stmt->fetchObject()) {
$settings[$obj->name] = $obj->value;
}
// Update settings
if ($settings) {
$image_list_dir = $settings['imagesdir'];
$image_public_path = $settings['imagesuri'];
$preview_css = $settings['cssuri'];