当前位置: 首页>>代码示例>>PHP>>正文


PHP Record::getConnection方法代码示例

本文整理汇总了PHP中Record::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::getConnection方法的具体用法?PHP Record::getConnection怎么用?PHP Record::getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Record的用法示例。


在下文中一共展示了Record::getConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dumpChildren

function dumpChildren($listhidden = 1, $parent_title = '', $root = 1, $slug = '')
{
    $tablename = TABLE_PREFIX . 'page';
    if ($slug != '') {
        $slug = $slug . '/';
    }
    if ($parent_title != '') {
        $parent_title = $parent_title . '/';
    }
    $sql = "SELECT title,slug FROM {$tablename} WHERE id='{$root}' AND " . ($listhidden ? "(status_id='100' OR (status_id='101' AND is_protected='0'))" : "status_id='100'") . ' ORDER BY title ASC';
    $PDO = Record::getConnection();
    $PDO->exec("set names 'utf8'");
    $settings = array();
    $stmt = $PDO->prepare($sql);
    $stmt->execute();
    while ($result = $stmt->fetchObject()) {
        if ($root > 1) {
            echo ',';
        }
        echo '["' . ($result->title == '' ? '' : $parent_title . $result->title) . '", "' . URL_PUBLIC . ($result->slug == '' ? '' : $slug . $result->slug . URL_SUFFIX) . '"]';
        $slug = $slug . $result->slug;
        $parent_title = $parent_title . $result->title;
    }
    $query = "SELECT id FROM {$tablename} WHERE parent_id='{$root}' AND " . ($listhidden ? "(status_id='100' OR (status_id='101' AND is_protected='0'))" : "status_id='100'") . ' ORDER BY title ASC';
    $stmt = $PDO->prepare($query);
    $stmt->execute();
    while ($result = $stmt->fetchObject()) {
        dumpChildren($listhidden, $parent_title, $result->id, $slug);
    }
}
开发者ID:nowotny,项目名称:wolf_ckeditor,代码行数:30,代码来源:pages_list.php

示例2: executioner

/**
 * Tagger Utilities
 */
function executioner($file_path, $params = array())
{
    $PDO = Record::getConnection();
    // Temporary variable, used to store current query
    $sql = '';
    // Read in entire file
    $lines = $file_path;
    // Loop through each line
    foreach ($lines as $line) {
        // Skip it if it's a comment
        if (substr($line, 0, 2) == '--' || $line == '') {
            continue;
        }
        // Add this line to the current segment
        $sql .= $line;
        // If it has a semicolon at the end, it's the end of the query
        if (substr(trim($line), -1, 1) == ';') {
            // Perform the query
            if (!empty($params)) {
                $sql = str_replace(array_keys($params), $params, $sql);
            }
            $PDO->exec($sql) or die('Error performing query \'<strong>' . $sql . '\': ' . mysql_error() . '<br /><br />');
            // Reset temp variable to empty
            $sql = '';
        }
    }
}
开发者ID:silentworks,项目名称:tagger,代码行数:30,代码来源:utils.php

示例3: pagesByTag

 public function pagesByTag($params = false)
 {
     $pdoConn = Record::getConnection();
     if (!$params) {
         $params = $this->params;
     }
     $pages = array();
     $tag_unslugified = unslugify(isset($params[0]) ? $params[0] : NULL);
     $tag = isset($params[0]) ? $params[0] : NULL;
     $where = " WHERE page.id = page_tag.page_id AND page_tag.tag_id = tag.id AND ((tag.name = '{$tag}') OR (tag.name = '{$tag_unslugified}'))" . " AND page.status_id != " . Page::STATUS_HIDDEN . " AND page.status_id != " . Page::STATUS_DRAFT . " ORDER BY page.created_on DESC";
     // Count rows in table
     $sql_count = "SELECT count(*) FROM " . TABLE_PREFIX . "page AS page, " . TABLE_PREFIX . "page_tag AS page_tag, " . TABLE_PREFIX . "tag AS tag" . $where;
     $query = $pdoConn->query($sql_count);
     if ($query->fetchColumn() > 0) {
         $sql = "SELECT page.* FROM " . TABLE_PREFIX . "page AS page, " . TABLE_PREFIX . "page_tag AS page_tag, " . TABLE_PREFIX . "tag AS tag" . $where;
         $stmt = $pdoConn->prepare($sql);
         $stmt->execute();
         while ($object = $stmt->fetchObject()) {
             $page = new PageTagger($object);
             // assignParts
             $page->part = Page::get_parts($page->id);
             $pages[] = $page;
         }
     } else {
         return false;
     }
     return $pages;
 }
开发者ID:silentworks,项目名称:tagger,代码行数:28,代码来源:tagger.php

示例4: select_album

function select_album()
{
    $sql = "SELECT * FROM ssp_albums";
    $query = Record::getConnection()->query($sql);
    $albums = $query->fetchAll();
    foreach ($albums as $album) {
        echo '<option value="' . $album['id'] . '">' . $album['name'] . '</option>';
    }
}
开发者ID:ariksavage,项目名称:wolf_ssp,代码行数:9,代码来源:ssp_manage.php

示例5: dashboard_events_widget_uninstall

function dashboard_events_widget_uninstall()
{
    $conn = Record::getConnection();
    if ($conn->exec("DROP TABLE IF EXISTS " . TABLE_PREFIX . "dashboard_log") === false) {
        Flash::set("error", __("Unable to drop table dashboard_log"));
        redirect(get_url("setting"));
        die;
    }
}
开发者ID:pawedWolf,项目名称:wolfcms-dashboard,代码行数:9,代码来源:index.php

示例6: albums

 public function albums()
 {
     $sql = "SELECT * FROM ssp_images WHERE did = " . $this->id;
     $query = Record::getConnection()->query($sql);
     $results = $query->fetchAll();
     $albums = array();
     foreach ($results as $album) {
         $albums[] = new SSP_Album($album['id']);
     }
     return $albums;
 }
开发者ID:ariksavage,项目名称:wolf_ssp,代码行数:11,代码来源:SSP_Gallery.php

示例7: images

 public function images()
 {
     $sql = "SELECT * FROM ssp_images WHERE aid = " . $this->id . " ORDER BY seq ASC";
     $query = Record::getConnection()->query($sql);
     $results = $query->fetchAll();
     $images = array();
     foreach ($results as $img) {
         $images[] = new SSP_Image($img['id']);
     }
     return $images;
 }
开发者ID:ariksavage,项目名称:wolf_ssp,代码行数:11,代码来源:SSP_Album.php

示例8: index

 function index()
 {
     $pdo = Record::getConnection();
     if ('mysql' == $pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
         /* Queries for MySQL */
         $this->display('dashboard/views/index', array('log_entry_today' => Record::findAllFrom('DashboardLogEntry', 'created_on > CURRENT_DATE() ORDER BY created_on DESC'), 'log_entry_yesterday' => Record::findAllFrom('DashboardLogEntry', 'created_on > DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) AND created_on < CURRENT_DATE() ORDER BY created_on DESC'), 'log_entry_older' => Record::findAllFrom('DashboardLogEntry', 'created_on < DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) AND created_on > DATE_SUB(CURRENT_DATE(), INTERVAL 3 MONTH) ORDER BY created_on DESC')));
     } else {
         /* Otherwise assume SQLite */
         $this->display('dashboard/views/index', array('log_entry_today' => Record::findAllFrom('DashboardLogEntry', "created_on > DATE('now') ORDER BY created_on DESC"), 'log_entry_yesterday' => Record::findAllFrom('DashboardLogEntry', "created_on > DATE('now', 'start of day', '-1 day') AND created_on < DATE('now', 'start of day') ORDER BY created_on DESC"), 'log_entry_older' => Record::findAllFrom('DashboardLogEntry', "created_on < DATE('now', 'start of day', '-1 day') ORDER BY created_on DESC")));
     }
 }
开发者ID:julpi,项目名称:freshcms_dashboard,代码行数:11,代码来源:DashboardController.php

示例9: checkOld

function checkOld()
{
    $tablename = TABLE_PREFIX . 'ckeditor';
    $PDO = Record::getConnection();
    $sql = "SELECT COUNT(*) FROM {$tablename}";
    $result = $PDO->query($sql);
    if ($result != null) {
        $result->closeCursor();
        return true;
    } else {
        return false;
    }
}
开发者ID:nowotny,项目名称:wolf_ckeditor,代码行数:13,代码来源:enable.php

示例10: clear

 function clear()
 {
     // TODO: replace this in future by Record's deleteAll routine.
     $pdo = Record::getConnection();
     $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
     if ($driver == 'mysql' || $driver == 'pgsql') {
         $sql = 'TRUNCATE ' . Record::tableNameFromClassName('DashboardLogEntry');
     }
     if ($driver == 'sqlite') {
         $sql = 'DELETE FROM ' . Record::tableNameFromClassName('DashboardLogEntry');
     }
     $pdo->exec($sql);
     redirect(get_url('plugin/dashboard/'));
 }
开发者ID:blr21560,项目名称:dashboard,代码行数:14,代码来源:DashboardController.php

示例11: __construct

 public function __construct($id = null)
 {
     if ($id !== null) {
         $sql = "SELECT * FROM wolf_ssp WHERE id=" . $id;
         $query = Record::getConnection()->query($sql);
         $bool = array('show_thumbnails', 'show_indicators', 'random', 'pause_on_hover', 'include_style');
         if ($ss = $query->fetch()) {
             foreach ($ss as $k => $v) {
                 if (in_array($k, $bool)) {
                     $v = $v == 1 ? true : false;
                 }
                 $this->{$k} = $v;
             }
         }
         if ($this->show_thumbnails) {
             $this->show_indicators = false;
         }
         $this->elid = 'ssp_slideshow_' . $this->id;
         if ($this->transition === null) {
             $this->transition = 'none';
         }
     }
     $album = new SSP_Album($this->aid);
     $i = 0;
     $this->slides = '';
     foreach ($album->images() as $img) {
         $this->slides .= $img->slide('slide' . $i);
         $i++;
     }
     $thumbnails = '';
     $i = 0;
     foreach ($album->images() as $img) {
         $this->thumbnails .= '<button id="btn' . $i . '" class="thumbnail';
         if ($i == 0) {
             $this->thumbnails .= ' active';
         }
         $this->thumbnails .= '" data-img="' . $img->src . '" onclick="goToSlide(' . $i . ', false);return false;">' . $i . '</button>';
         $i++;
     }
     $indicators = '';
     $i = 0;
     foreach ($album->images() as $img) {
         $this->indicators .= '<button id="btn' . $i . '" class="indicator';
         if ($i == 0) {
             $this->indicators .= ' active';
         }
         $this->indicators .= '" onclick="goToSlide(' . $i . ', false);return false;">' . $i . '</button>';
         $i++;
     }
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:50,代码来源:SSP_Slideshow.php

示例12: __construct

 public function __construct($id)
 {
     $settings = Plugin::getAllSettings('ssp');
     $this->id = $id;
     $sql = "SELECT * FROM ssp_images WHERE id=" . $id;
     $query = Record::getConnection()->query($sql);
     $image = $query->fetch();
     foreach ($image as $k => $v) {
         $this->{$k} = $v;
     }
     $this->src = URL_PUBLIC . $settings['path'] . DS . "albums" . DS . "album-" . $this->aid . DS . "lg" . DS . $this->src;
     if (!(strpos('http://', $this->link) > -1) && $this->link[0] !== '/' && isset($this->link)) {
         $this->link = 'http://' . $this->link;
     }
 }
开发者ID:ariksavage,项目名称:wolf_ssp,代码行数:15,代码来源:SSP_Image.php

示例13: behavior_page_not_found

/**
 * Presents browser with a custom 404 page.
 */
function behavior_page_not_found()
{
    $sql = 'SELECT * FROM ' . TABLE_PREFIX . "page WHERE behavior_id='page_not_found'";
    $stmt = Record::getConnection()->prepare($sql);
    $stmt->execute();
    $page = $stmt->fetchObject();
    if ($page) {
        $page = Page::find_page_by_uri($page->slug);
        if (is_object($page)) {
            header("HTTP/1.0 404 Not Found");
            header("Status: 404 Not Found");
            $page->_executeLayout();
            exit;
            // need to exit otherwise true error page will be sent
        }
    }
}
开发者ID:sindotnet,项目名称:dashhotel,代码行数:20,代码来源:index.php

示例14: __construct

 public function __construct($id = null)
 {
     if ($id !== null) {
         $sql = "SELECT * FROM wolf_ssp WHERE id=" . $id;
         $query = Record::getConnection()->query($sql);
         $bool = array('show_indicators', 'random', 'pause_on_hover', 'include_style');
         if ($ss = $query->fetch()) {
             foreach ($ss as $k => $v) {
                 if (in_array($k, $bool)) {
                     $v = $v == 1 ? true : false;
                 }
                 $this->{$k} = $v;
             }
         }
         $this->elid = 'ssp_slideshow_' . $this->id;
     }
 }
开发者ID:ariksavage,项目名称:wolf_ssp,代码行数:17,代码来源:SSP_Slideshow.php

示例15: add_category

 public function add_category()
 {
     $this->_checkPermission();
     $category_name = $_POST['category_name'];
     if (empty($_POST['category_name'])) {
         Flash::set('error', __('You have to specify a category title!'));
         redirect(get_url('news'));
     }
     $sql = "Insert into " . TABLE_PREFIX . "newscategory VALUES(0,'" . addslashes($category_name) . "','0','1','" . date("Y-m-d") . "', '', " . AuthUser::getId() . ", '')";
     Record::query($sql);
     $PDO = Record::getConnection();
     $last_id = $PDO->lastInsertId();
     //Create album folder
     $album_dir = FILES_DIR . '/news/images/' . $last_id;
     if (mkdir($album_dir)) {
         chmod($album_dir, 0777);
     }
     Flash::set('success', __('News category has been created.'));
     redirect(get_url('news'));
 }
开发者ID:sindotnet,项目名称:canareef,代码行数:20,代码来源:NewsController.php


注:本文中的Record::getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。