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


PHP Record::findOneFrom方法代码示例

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


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

示例1: add

 public function add($parent_id = 1)
 {
     // check if trying to save
     if (get_request_method() == 'POST') {
         return $this->_add();
     }
     $data = Flash::get('post_data');
     $page = new Page($data);
     $page->parent_id = $parent_id;
     $page->status_id = Setting::get('default_status_id');
     $page->needs_login = Page::LOGIN_INHERIT;
     $page_parts = Flash::get('post_parts_data');
     if (empty($page_parts)) {
         // check if we have a big sister ...
         $big_sister = Record::findOneFrom('Page', 'parent_id=? ORDER BY id DESC', array($parent_id));
         if ($big_sister) {
             // get all is part and create the same for the new little sister
             $big_sister_parts = Record::findAllFrom('PagePart', 'page_id=? ORDER BY id', array($big_sister->id));
             $page_parts = array();
             foreach ($big_sister_parts as $parts) {
                 $page_parts[] = new PagePart(array('name' => $parts->name, 'filter_id' => Setting::get('default_filter_id')));
             }
         } else {
             $page_parts = array(new PagePart(array('filter_id' => Setting::get('default_filter_id'))));
         }
     }
     // display things ...
     $this->setLayout('backend');
     $this->display('page/edit', array('action' => 'add', 'page' => $page, 'tags' => array(), 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $page_parts, 'layouts' => Record::findAllFrom('Layout')));
 }
开发者ID:julpi,项目名称:FreshCMS,代码行数:30,代码来源:PageController.php

示例2: add

 /**
  * Action to add a page.
  *
  * @param int $parent_id The page id for the new page's parent. Defaults to page 1.
  * @return <type>
  */
 public function add($parent_id = 1)
 {
     // Check if trying to save.
     if (get_request_method() == 'POST') {
         return $this->_store('add');
     }
     // If not trying to save, display "Add page" view.
     $data = Flash::get('post_data');
     $page = new Page($data);
     $page->parent_id = $parent_id;
     $page->status_id = Setting::get('default_status_id');
     $page->needs_login = Page::LOGIN_INHERIT;
     $page_parts = Flash::get('post_parts_data');
     if (empty($page_parts)) {
         // Check if we have a big sister.
         $big_sister = Record::findOneFrom('Page', 'parent_id=? ORDER BY id DESC', array($parent_id));
         if ($big_sister) {
             // Get list of parts create the same for the new little sister
             $big_sister_parts = Record::findAllFrom('PagePart', 'page_id=? ORDER BY id', array($big_sister->id));
             $page_parts = array();
             foreach ($big_sister_parts as $parts) {
                 $page_parts[] = new PagePart(array('name' => $parts->name, 'filter_id' => Setting::get('default_filter_id')));
             }
         } else {
             $page_parts = array(new PagePart(array('filter_id' => Setting::get('default_filter_id'))));
         }
     }
     // Display actual view.
     $this->setLayout('backend');
     $this->display('page/edit', array('action' => 'add', 'csrf_token' => SecureToken::generateToken(BASE_URL . 'page/add'), 'page' => $page, 'tags' => array(), 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $page_parts, 'layouts' => Record::findAllFrom('Layout')));
 }
开发者ID:chaobj001,项目名称:tt,代码行数:37,代码来源:PageController.php

示例3: save

 function save()
 {
     $data = $_POST['redirect'];
     if (empty($data['url'])) {
         Flash::set('error', __('You have to specify a url!'));
         redirect(get_url('plugin/redirector/'));
     }
     if (empty($data['destination'])) {
         Flash::set('error', __('You have to specify a destination url!'));
         redirect(get_url('plugin/redirector/'));
     }
     if ($existing_redirect = Record::findOneFrom('RedirectorRedirects', 'url = \'' . ($data['url'] . '\''))) {
         Record::update('RedirectorRedirects', array('url' => $data['url'], 'destination' => $data['destination']), 'url = \'' . ($data['url'] . '\''));
     } else {
         $entry = new RedirectorRedirects($data);
         if (!$entry->save()) {
             Flash::set('error', __('There was a problem adding your redirect.'));
         } else {
             if ($error = Record::findOneFrom('Redirector404s', 'url = \'' . ($data['url'] . '\''))) {
                 $error->delete();
             }
             Flash::set('success', __('Redirect has been added!'));
         }
     }
     redirect(get_url('plugin/redirector/'));
 }
开发者ID:julpi,项目名称:FreshCMS,代码行数:26,代码来源:RedirectorController.php

示例4: findBy

 public function findBy($column, $value)
 {
     //$where = "{$column} = '{$value}'";
     $where = $column . "='?'";
     $userinfo = Record::findOneFrom('User', $where, array($value));
     if ($userinfo) {
         $this->setFromData($userinfo);
     }
 }
开发者ID:chaobj001,项目名称:tt,代码行数:9,代码来源:User.class.php

示例5: deletePageTagRelationship

 public static function deletePageTagRelationship($page_id, $tag_id)
 {
     // get the id of the tag
     $tag = Record::findOneFrom('Tag', 'id=?', array($tag_id));
     Record::deleteWhere('PageTag', 'page_id=? AND tag_id=?', array($page_id, $tag->id));
     $tag->count--;
     $tag->save();
     return true;
 }
开发者ID:silentworks,项目名称:tagger,代码行数:9,代码来源:TaggerTag.php

示例6: findBy

 public function findBy($column, $value)
 {
     //$where = "{$column} = '{$value}'";
     //$where = "id='?'";
     $where = "{$column} = '?'";
     $category_info = Record::findOneFrom('Category', $where, array($value));
     if ($category_info) {
         $this->setFromData($category_info);
     }
 }
开发者ID:chaobj001,项目名称:tt,代码行数:10,代码来源:Category.class.php

示例7: save_by_page

 /**
  * 
  * @param integer|Model_Page_Front $page_id
  * @param array $tags
  */
 public static function save_by_page($page_id, $tags)
 {
     if (is_string($tags)) {
         $tags = explode(Model_Tag::SEPARATOR, $tags);
     }
     $tags = array_unique(array_map('trim', $tags));
     $current_tags = Model_Page_Tag::find_by_page($page_id);
     if ($page_id instanceof Model_Page_Front) {
         $page_id = $page_id->id();
     }
     // no tag before! no tag now! ... nothing to do!
     if (empty($tags) and empty($current_tags)) {
         return NULL;
     }
     // delete all tags
     if (empty($tags)) {
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             DB::update(Model_Tag::tableName())->set(array('count' => DB::expr('count - 1')))->where('name', '=', $tag)->execute();
         }
         Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id))));
         Cache::instance()->delete_tag('page_tags');
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (empty($tag_name)) {
                 continue;
             }
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             // try to get it from tag list, if not we add it to the list
             if (!$tag instanceof Model_Tag) {
                 $tag = new Model_Tag(array('name' => trim($tag_name)));
             }
             $tag->count++;
             $tag->save();
             // create the relation between the page and the tag
             $page_tag = new Model_Page_Tag(array('page_id' => (int) $page_id, 'tag_id' => $tag->id));
             $page_tag->save();
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id), array('tag_id', '=', $tag->id))));
             $tag->count--;
             $tag->save();
         }
         Cache::instance()->delete_tag('page_tags');
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:57,代码来源:tag.php

示例8: getCurrentVersionFrom

 public static function getCurrentVersionFrom($page)
 {
     $page_id = null;
     if (is_numeric($page)) {
         $page_id = $page;
     } else {
         if ($page instanceof Page) {
             $page_id = $page->id;
         }
     }
     //$current_version = $page->children(array('where' => 'behavior_id="current_version"', 'limit' => 1), array(), true);
     $current_version = Record::findOneFrom("PageVersion", 'parent_id = ' . $page_id . ' and behavior_id="current_version"');
     return $current_version;
 }
开发者ID:julpi,项目名称:freshcms_page_versions,代码行数:14,代码来源:PageVersion.php

示例9: findBy

 public static function findBy($column, $value)
 {
     return Record::findOneFrom('ExperienceImage', $column . ' = ?', array($value));
 }
开发者ID:sindotnet,项目名称:canareef,代码行数:4,代码来源:ExperienceImage.php

示例10: saveTags

 public function saveTags($tags)
 {
     if (is_string($tags)) {
         $tags = explode(',', $tags);
     }
     $tags = array_map('trim', $tags);
     $current_tags = $this->getTags();
     // no tag before! no tag now! ... nothing to do!
     if (count($tags) == 0 && count($current_tags) == 0) {
         return;
     }
     // delete all tags
     if (count($tags) == 0) {
         $tablename = self::tableNameFromClassName('Tag');
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             self::$__CONN__->exec("UPDATE {$tablename} SET count = count - 1 WHERE name = '{$tag}'");
         }
         return Record::deleteWhere('PageTag', 'page_id=?', array($this->id));
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (!empty($tag_name)) {
                 // try to get it from tag list, if not we add it to the list
                 if (!($tag = Record::findOneFrom('Tag', 'name=?', array($tag_name)))) {
                     $tag = new Tag(array('name' => trim($tag_name)));
                 }
                 $tag->count++;
                 $tag->save();
                 // create the relation between the page and the tag
                 $tag = new PageTag(array('page_id' => $this->id, 'tag_id' => $tag->id));
                 $tag->save();
             }
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Record::findOneFrom('Tag', 'name=?', array($tag_name));
             Record::deleteWhere('PageTag', 'page_id=? AND tag_id=?', array($this->id, $tag->id));
             $tag->count--;
             $tag->save();
         }
     }
 }
开发者ID:chaobj001,项目名称:tt,代码行数:46,代码来源:Page.php

示例11: Gallery

} else {
    $isRoot = 0;
}
$oGallery = new Gallery();
$count = 0;
if ($isRoot == 1) {
    // album cover
    $albums = Record::query("select a.page_id, a.id, a.name as album_name from wolf_album a,wolf_page p where a.id=p.id AND a.status='1' group by a.id order by p.position asc");
} else {
    // loop photos
    $albums = Record::query("select a.page_id, a.id, a.name as album_name,g.* from wolf_gallery g inner join wolf_album a on a.id=g.album_id AND a.status='1' AND a.page_id='" . $this->id . "' where g.status='1' order by g.sequence asc, g.id desc");
}
while ($album = $albums->fetchObject()) {
    $count++;
    //Album cover
    $cover = Record::findOneFrom("Gallery", "status='1' and album_id='" . $album->id . "' order by sequence asc LIMIT 1");
    if ($isRoot == 1) {
        $url = Page::urlById((int) $album->page_id);
        $img_src = $cover->filename != "" ? URL_PUBLIC . 'public/gallery/images/' . $album->id . '/' . $cover->filename : THEME_PATH . 'js/gallery/broken_image.jpg';
        echo '<div class="album-cover">
					<div><a href="' . $url . '">
						<img id="cover' . $album->id . '" src="' . $img_src . '" border=0>
					</a></div>
					<p>' . $album->album_name . '</p>
				</div>
			';
    } else {
        //Link that triggers the popup
        $img_src = $album->filename != "" ? URL_PUBLIC . 'public/gallery/images/' . $album->album_id . '/' . $album->filename : THEME_PATH . 'js/gallery/broken_image.jpg';
        echo '<div class="album-cover">
				<div><a href="' . URL_PUBLIC . 'public/gallery/images/' . $album->album_id . '/' . $album->filename . '" rel="photo[' . $album->album_id . ']">
开发者ID:sindotnet,项目名称:hotelyan,代码行数:31,代码来源:gallery-album.php

示例12: isInstalled

 public static function isInstalled($theme_id)
 {
     $theme = Record::findOneFrom('Themr', 'name=?', array($theme_id));
     if (isset($theme->id)) {
         return true;
     }
     return false;
 }
开发者ID:silentworks,项目名称:themr,代码行数:8,代码来源:Themr.php

示例13: findBy

 public function findBy($column, $value)
 {
     //$where = "{$column} = '{$value}'";
     //$where = "id='?'";
     $where = "{$column} = '?'";
     $article_info = Record::findOneFrom('Article', $where, array($value));
     if ($article_info) {
         $this->setFromData($article_info);
     }
     return $article_info;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:11,代码来源:Article.class.php

示例14: uninstall

 /**
  * Uninstall a theme along with snippets that came with it.
  *
  * @since 0.1.0
  *
  */
 public function uninstall($id)
 {
     $layoutUsed = 0;
     $theme = Record::findOneFrom('Themr', 'name=?', array($id));
     // Get Current Theme Info
     $theme_info = Themr::findTheme($id);
     foreach (unserialize($theme->layout) as $layouts) {
         // find the user to delete
         if ($layout = Record::findOneFrom('Layout', 'name=?', array(Themr::theme_name($layouts)))) {
             if ($layout->isUsed()) {
                 Flash::set('error', __('Theme <b>:theme</b> CANNOT be deleted because layout <b>:name</b> is being used!', array(':name' => $layout->name, ':theme' => $theme_info['name'])));
                 $layoutUsed = 1;
             } else {
                 if ($layout->delete()) {
                     Flash::set('success', __('Layout <b>:name</b> has been deleted!', array(':name' => $layout->name)));
                 } else {
                     Flash::set('error', __('Layout <b>:name</b> has not been deleted!', array(':name' => $layout->name)));
                 }
             }
         } else {
             Flash::set('error', __('Layout not found!'));
         }
     }
     if ($layoutUsed !== 1) {
         foreach (unserialize($theme->snippet) as $snippets) {
             // find the snippet to delete
             if ($snippet = Record::findOneFrom('Snippet', 'name=?', array($snippets))) {
                 if ($snippet->delete()) {
                     Flash::set('success', __('Snippet <b>:name</b> has been deleted!', array(':name' => $snippet->name)));
                 } else {
                     Flash::set('error', __('Snippet <b>:name</b> has not been deleted!', array(':name' => $snippet->name)));
                 }
             } else {
                 Flash::set('error', __('Snippet not found!'));
             }
         }
         if ($theme->delete()) {
             Flash::set('success', __('Theme <b>:name</b> has been uninstalled!', array(':name' => $theme_info['name'])));
             redirect(get_url('plugin/themr'));
         } else {
             Flash::set('error', __('Theme <b>:name</b> has not been uninstalled!', array(':name' => $theme_info['name'])));
             redirect(get_url('plugin/themr'));
         }
     } else {
         redirect(get_url('plugin/themr'));
     }
 }
开发者ID:silentworks,项目名称:themr,代码行数:53,代码来源:ThemrController.php

示例15: getTokenTime

 private static final function getTokenTime($username, $url)
 {
     use_helper('Hash');
     $hash = new Crypt_Hash('sha256');
     $time = 0;
     if ($token = Record::findOneFrom('SecureToken', "username = ? AND url = ?", array($username, bin2hex($hash->hash($url))))) {
         $time = $token->time;
     }
     return $time;
 }
开发者ID:julpi,项目名称:FreshCMS,代码行数:10,代码来源:SecureToken.php


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