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


PHP Typeframe::Database方法代码示例

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


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

示例1: load

 public function load()
 {
     $this->_data = array();
     $host = 'http://' . $_SERVER['SERVER_NAME'];
     // This will retrieve all the content pages.
     if (Typeframe::Registry()->application('Content')) {
         $query = "SELECT uri, nickname,\tapplication FROM #__page";
         $rs = Typeframe::Database()->prepare($query);
         $rs->execute();
         while ($data = $rs->fetch_array()) {
             $this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $data['uri'], 'uri' => $data['uri'], 'name' => $data['nickname'] != '' ? $data['nickname'] : $data['uri'], 'application' => $data['application']);
         }
     }
     // And the news pages.
     if (Typeframe::Registry()->application('News')) {
         $select = new BuildSql_Select();
         $select->table('#__news n');
         $select->leftJoin('#__news_category ncat', 'ncat.categoryid = n.categoryid');
         $select->field('n.*');
         $select->field('ncat.categoryname');
         $select->group('n.newsid');
         $select->order('n.pubdate DESC');
         $select->where('n.pubdate <= ?', Typeframe::Now());
         $rs = $this->db()->prepare($select->query());
         $rs->execute();
         while ($row = $rs->fetch_array()) {
             $uri = News::GetCategoryUri($row['categoryid']) . '/' . ($row['encodedtitle'] ? $row['encodedtitle'] : $row['newsid']);
             $this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $uri, 'uri' => $uri, 'name' => $row['title'], 'application' => $row['categoryname']);
         }
     }
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:31,代码来源:Sitemap.php

示例2: output

 public function output(PMDataNode $data)
 {
     $pm = new Pagemill($data->fork());
     //$pm->setVariableArray($this->settings);
     $db = Typeframe::Database();
     if (!isset($this->settings['driver'])) {
         //return '<div class="error"><p>Please provide a "driver" attribute on the pm:driver plugin.</p></div>';
         return '';
     }
     // Blank driver attributes count as nothing too.
     if (!$this->settings['driver']) {
         return '';
     }
     // I need to lookup this driver as a page and ensure it's a valid driver.
     $driver = (int) $this->settings['driver'];
     $rs = $db->prepare('SELECT uri, nickname, driver FROM #__page WHERE driver != "" AND pageid = ?');
     $rs->execute($driver);
     if (!$rs->recordcount()) {
         // No records found... just silently fail.
         return '';
     }
     $data = $rs->fetch_array();
     $pm->setVariable('link', TYPEF_WEB_DIR . $data['uri']);
     $pm->setVariable('title', $data['nickname']);
     $pm->setVariable('driver', $data['driver']);
     return $pm->writeText('<pm:include template="/plugins/driver.html" />');
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:27,代码来源:Driver.php

示例3: output

 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $db = Typeframe::Database();
     if ($this->hasAttribute('rules') && !Typeframe_Tag_Socket::ProcessRules($this->getAttribute('rules'))) {
         return '';
     }
     /*
      * Rules for loading the plugin:
      * 1. The plugid overrides other load settings.
      * 2. Load a plugin from the table if the name attribute matches an
      *    an admin-specified name.
      * 3. Create a generic plugin from a signature.
      * 4. If the plugin was loaded from the database, attribute settings
      *    override database settings.
      */
     $p = null;
     if ($this->getAttribute('plugid')) {
         $plugin = Model_Plug::Get($data->parseVariables($this->getAttribute('plugid')));
         if ($plugin->exists()) {
             $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
         }
     } else {
         if ($this->getAttribute('name')) {
             $plugins = new Model_Plug();
             $plugins->where('name = ?', $data->parseVariables($this->getAttribute('name')));
             $plugin = $plugins->getFirst();
             if ($plugin->exists()) {
                 $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
             } else {
                 $p = Typeframe::Registry()->getPluginSignature($this->getAttribute('name'));
             }
         }
     }
     if ($p) {
         $cls = $p->className();
         if (class_exists($cls)) {
             $settings = $this->settings;
             foreach ($this->attributes() as $k => $v) {
                 $settings[$k] = $data->parseVariables($v);
             }
             //$obj = new $cls($settings);
             $obj = new $cls('plugin', $settings, null);
             foreach ($this->children() as $child) {
                 $obj->appendChild($child);
             }
             $obj->process($data, $stream);
             foreach ($obj->children() as $child) {
                 $this->appendChild($child);
             }
             $obj->detach();
         } else {
             throw new Exception("Class '{$cls}' does not exist");
         }
     } else {
         throw new Exception("Plugin does not have a signature");
     }
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:57,代码来源:Plugin.php

示例4: output

 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $data = $data->fork();
     if (!empty($this->attributes['menuplugid'])) {
         $menuplugid = $this->attributes['menuplugid'];
         $db = Typeframe::Database();
         $base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR));
         if ($base == '') {
             $base = '/';
         }
         $search = new Model_Nav();
         $search->where('plugid = ?', $menuplugid);
         $search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid());
         foreach ($search->select() as $current) {
             $current['url'] = $this->_convertUrl($current['url']);
             $data->set('current', $current);
             $parentid = $current['parent'];
             $siblings = new Model_Nav();
             $siblings->where('plugid = ?', $menuplugid);
             $siblings->where('parent = ?', $parentid);
             $siblings->order('sortnum');
             $data['siblings'] = $siblings;
             /*$sibArray = array();
             		foreach ($siblings->select() as $sib) {
             			$sib['url'] = $this->_convertUrl($sib['url']);
             			$sibArray[] = $sib;
             		}
             		$data['siblings'] = $sibArray;*/
             if (!empty($this->attributes['showparent'])) {
                 $parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid);
                 foreach ($parent as $par) {
                     $par['url'] = $this->_convertUrl($par['url']);
                     $data->set('parent', $par);
                 }
             }
             if (!empty($this->attributes['showchildren'])) {
                 $childArray = array();
                 $children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum');
                 foreach ($children as $chi) {
                     $chi['url'] = $this->_convertUrl($chi['url']);
                     $childArray[] = $chi;
                 }
                 $data['children'] = $childArray;
             }
         }
     }
     $this->pluginTemplate = "navigation/submenu.plug.html";
     parent::output($data, $stream);
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:49,代码来源:Submenu.php

示例5: allow

 public function allow()
 {
     if (!Typeframe::User()->loggedIn()) {
         return false;
     }
     if (Typeframe::User()->get('usergroupid') == TYPEF_ADMIN_USERGROUPID) {
         return true;
     }
     $relativeUri = substr($this->page()->uri(), strlen(TYPEF_WEB_DIR));
     if ($relativeUri == '/admin' || $relativeUri == '/admin/') {
         // Main admin page.  Just check to see if the user has access to any other applications.
         $rs = Typeframe::Database()->execute('SELECT * FROM #__usergroup_admin WHERE usergroupid = ' . Typeframe::User()->get('usergroupid'));
         return count($rs) > 0;
     }
     $rs = Typeframe::Database()->execute('SELECT * FROM #__usergroup_admin WHERE usergroupid = ' . Typeframe::User()->get('usergroupid') . ' AND application = \'' . $this->page()->application()->name() . '\'');
     return $rs->count() > 0;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:17,代码来源:Admin.php

示例6: makeFriendlyUrlText

function makeFriendlyUrlText($string, $query = null)
{
    // DO NOT pass an entire URL into this function.  It'll just get mangled.
    // Pass text that needs to be made friendly for insertion into a path, such as the
    // title of an article.
    $result = strtolower($string);
    $result = str_replace("'", '', $result);
    $result = preg_replace('/[^a-z0-9]+/', '-', $result);
    $result = preg_replace('/[\\-]+/', '-', $result);
    // Maximum length for each unit (assumed here to be used as a single directory name)
    // is 60 characters, plus a numeric ID in the case of duplicated titles
    if (strlen($result) > 60) {
        $result = substr($result, 0, 100);
        if (substr($result, 59) == '-') {
            $result = substr($result, 0, 99);
        }
    }
    if ($result[0] == '-') {
        $result = substr($result, 1);
    }
    if (substr($result, strlen($result) - 1) == '-') {
        $result = substr($result, 0, strlen($result) - 1);
    }
    if (!is_null($query)) {
        // Make sure the text does not already exist in the specified query
        // The query should include a parameter for the text (e.g.: SELECT * FROM table WHERE url = ?)
        $rs = Typeframe::Database()->prepare($query);
        $checked = $result;
        $num = 0;
        $rs->execute($checked);
        while ($rs->recordcount() > 0) {
            $num++;
            $checked = $result . '-' . $num;
            $rs->execute($checked);
        }
        $result = $checked;
    }
    return $result;
}
开发者ID:ssrsfs,项目名称:blg,代码行数:39,代码来源:functions.php

示例7: IncludeScript

 /**
  * Include (evaluate) a file in the source/scripts directory.
  * @param string $script The relative path to the file.
  */
 public static function IncludeScript($script)
 {
     // TODO: Get rid of these variables.  They should be declared explicitly in the controller if necessary.
     $pm = Typeframe::Pagemill();
     $db = Typeframe::Database();
     include_once TYPEF_SOURCE_DIR . '/scripts' . $script;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:11,代码来源:Typeframe.php

示例8: array

<?php

$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
Typeframe::SetPageTemplate('/admin/applications/index.html');
foreach (Typeframe::Registry()->applications() as $a) {
    $app = array('name' => $a->name(), 'title' => $a->title(), 'map' => $a->map());
    $pm->addLoop('applications', $app);
    if ($a->map() == 'hard') {
        $pm->addLoop('applications', 'pages', array('uri' => TYPEF_WEB_DIR . $a->base()));
    } else {
        // TODO: Figure out what to do about soft-mapped pages
        /*
        foreach (Typeframe::Registry()->getApplicationPagesByName($a->name()) as $p) {
        	$pm->addLoop('applications', 'pages', array('uri' => $p->uri()));
        }
        */
    }
}
$pm->sortLoop('applications', 'name');
开发者ID:ssrsfs,项目名称:blg,代码行数:20,代码来源:index.php

示例9: _Include

 private static function _Include($file, Pagemill $pm)
 {
     $db = Typeframe::Database();
     include $file;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:5,代码来源:Response.php

示例10: _IncludeController

 private static function _IncludeController($filename)
 {
     // TODO: Get rid of these variables.  They should be declared explicitly in the controller if necessary.
     $pm = Typeframe::Pagemill();
     $db = Typeframe::Database();
     include $filename;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:7,代码来源:Page.dep.php

示例11: array

     if ($column['Extra'] == 'auto_increment') {
         $autoIncrement = true;
     }
     $xlate = array();
     $xlate['name'] = $column['Field'];
     /*if (substr($column['Type'], 0, 3) == 'int') {
     			// integer
     		} else if (substr($column['Type'], 0, 7) == 'varchar') {
     			// varchar
     		}*/
     $xlate['type'] = addslashes($column['Type']);
     $xlate['allownull'] = $column['Null'] == 'NO' ? false : true;
     $xlate['defaultvalue'] = $column['Default'];
     $columns[] = $xlate;
 }
 $rsIndexes = Typeframe::Database()->execute('SHOW INDEX IN ' . $tableName);
 $indexes = array();
 foreach ($rsIndexes as $index) {
     $name = strtolower($index['Key_name']);
     if (!isset($indexes[$name])) {
         $indexes[$name] = array();
         $indexes[$name]['name'] = $name;
         $indexes[$name]['unique'] = $index['Non_unique'] == 0 ? true : false;
         $indexes[$name]['columns'] = array();
     }
     $indexes[$name]['columns'][] = array('name' => $index['Column_name']);
 }
 $classMill = new Pagemill();
 $classMill->setVariable('class', $className);
 $classMill->setVariable('table', $shortName);
 $classMill->setVariable('prefix', $prefix);
开发者ID:ssrsfs,项目名称:blg,代码行数:31,代码来源:dbimport.inc.php

示例12: update

 public function update(array $input = null)
 {
     //gimme life!
     //$item = isset($_POST['itemid']) ? new Navigation_Item($_POST['itemid']) : new Navigation_Item();
     $item = isset($_POST['itemid']) && !is_array($_POST['itemid']) ? Model_Nav::Get($_POST['itemid']) : Model_Nav::Create();
     if ($_REQUEST['cmd'] != 'delete' && $_REQUEST['cmd'] != 'name' && $_REQUEST['cmd'] != 'sort') {
         $item->set('pageid', 0);
         switch ($_POST['type']) {
             case 'none':
                 // Heh, these have no extra attributes, so null just about everything.
                 $item->set('label', $_POST['label']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'always');
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
             case 'int':
                 $item->set('label', $_POST['label']);
                 $item->set('pageid', $_POST['pageid']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'permitted');
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'arbint':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'ext':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'mailto':
                 $item->set('label', $_POST['label']);
                 $item->set('url', 'mailto:' . $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
         }
     }
     switch ($_REQUEST['cmd']) {
         case 'add':
             $item->set('parent', $_POST['parent']);
             $item->set('plugid', $_POST['plugid']);
             $result = Typeframe::Database()->execute('SELECT MAX(sortnum) AS maxsort FROM #__nav WHERE plugid = ' . (int) $_POST['plugid']);
             $max = $result[0];
             $item->set('sortnum', $max['maxsort'] + 1);
             $item->save();
             $msg = " Added";
             break;
         case 'edit':
             $item->save();
             $msg = " Saved";
             break;
         case 'delete':
             $item->delete();
             $msg = " Deleted";
             break;
         case 'name':
             $plug = Model_Plug::Get($_POST['plugid']);
             $plug['name'] = $_POST['name'];
             $plug->save();
             Typeframe::Redirect('Name updated.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
         case 'sort':
             $sortnum = 1;
             for ($i = 0; $i < count($_POST['itemid']); $i++) {
                 $item = Model_Nav::Get($_POST['itemid'][$i]);
                 $item['parent'] = $_POST['parent'][$i];
                 $item['sortnum'] = $sortnum;
                 $item->save();
                 $sortnum++;
             }
             Typeframe::Redirect('Items sorted.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
     }
     Typeframe::Redirect('Item' . $msg, Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:90,代码来源:Menu.php

示例13: pathinfo

        $pathinfo = pathinfo($file);
        if ($pathinfo['extension'] == 'php') {
            $models[] = 'BaseModel_' . $pathinfo['filename'];
        }
    }
}
$tables = array();
$result = Typeframe::Database()->execute('SHOW TABLES');
foreach ($result as $row) {
    $row = $row->getArray();
    //var_dump($row);
    $tableName = array_pop($row);
    $columns = array();
    //$rsCol = Typeframe::Database()->prepare('SHOW COLUMNS IN `' . $tableName . '`');
    //$rsCol->execute();
    $cols = Typeframe::Database()->execute('SHOW COLUMNS IN `' . $tableName . '`');
    //while ($col = $rsCol->fetch_array()) {
    foreach ($cols as $col) {
        $columns[] = $col['Field'];
    }
    $tables[$tableName] = $columns;
}
foreach (array_keys($tables) as $table) {
    $cls = className($table);
    if (!in_array($cls, $models)) {
        echo "The {$table} table does not have a BaseModel class.\n";
        $diffs++;
    } else {
        $mod = new $cls();
        foreach ($tables[$table] as $fld) {
            if (!$mod->field($fld)) {
开发者ID:ssrsfs,项目名称:blg,代码行数:31,代码来源:dbdiff.inc.php

示例14: SetUID

 /**
  * Saves the userID in the session database for logging in (or out) the user.
  *
  * @param int $uid
  */
 public static function SetUID($uid)
 {
     Typeframe::Database()->prepare("UPDATE `#__sessions`\r\n      SET `uid` = ?\r\n      WHERE `sid` = ? AND `ip_addr` = ?\r\n      LIMIT 1 ;")->execute($uid, Session::$sid, REMOTE_IP);
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:9,代码来源:session.class.php


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