- 浏览: 598905 次
- 性别:
- 来自: 上海
-
最新评论
-
天使建站:
http://www.aijquery.cn/Html/bia ...
jquery searchableselect用法 -
天使建站:
http://www.aijquery.cn/Html/bia ...
jquery searchableselect用法 -
hudeyong926:
这技术太老了
PHP生成桌面快捷方式 -
hnlixf:
参考 http://www.jb51.net/article/ ...
ThinkPHP 3.3.2使用PHPExcel实现Excel数据导入导出完整实例 -
hudeyong926:
magento,清空购物车中所有的产品和session
文章列表
yii之函数countBySql()
- 博客分类:
- PHP
countBySql()源代码如下:
public function countBySql($sql,$params=array())
{
Yii::trace(get_class($this).'.countBySql()','system.db.ar.CActiveRecord');
return $this->getCommandBuilder()->createSqlCommand($sql,$params)->queryScalar();
}
实际上countBySql()还是调用了CDbCommand::queryScalar ...
YIIl的layout套用
- 博客分类:
- PHP
最低层layout:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
<?php echo $content; ?>
</body>
</html>
各模块的layout:
<?php $this->beginContent('application.views.layouts.main'); ?>
...
yii利用Clip构建界面
- 博客分类:
- PHP
Yii为我们提供了layout,我们可以把一个view嵌入设计好的layout。但随着网站设计越来越多变,越来越复杂,只是layout内一个$content 变量在载入view似乎并不能满足我们的需求。如果页面中有好几个地方需要时时变动呢?
没关系, Yii还为我们提供了Clip这个方法,这个其实有点类似与Django中的block。
比如现在我们需要构建一个布局,左边是主要内容,侧边栏上有个子菜单和一段介绍文字,在每个不同的页面上,子菜单和介绍文字都是是不同的。让我们看看代码,这个应该更直接:
<!DOCTYPE html PUBLIC "-//W3C//DT ...
Yii框架自带缓存的使用方法
- 博客分类:
- PHP
Yii的自带缓存都继承CCache 类, 在使用上基本没有区别
缓存基础类 CCache 提供了两个最常用的方法:set() 和 get()。
要在缓存中存储变量 $value,我们选择一个唯一 ID 并调用 set() 来存储它:
Yii::app()->cache->set($id, $value);
被缓存的数据会一直保留在缓存中,直到因一些缓存策略而被删除(比如缓存空间满了,删除最旧的数据)。要改变这一行为,我们还可以在调用 set() 时加一个过期参数,这样数据过一段时间就会自动从缓存中清除。
// 在缓存中保留该值最多 30 秒
Yii::app()-&g ...
在Block类的_construct(不是构造方法)方法中加入以下代码:
Php代码
public function _construct()
{
$this->addData(
array(
'cache_lifetime' => 3600,
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG),
...
Magento 常用技巧与方法
- 博客分类:
- PHP
资料来自网络,大部分没有经过验证,仅供参考:
1.属性Attribute
产品属性操作:
$product = Mage::getModel('catalog/product')->getCollection()->getFirstItem();
foreach($product->getAttributes() as $att) {
$group_id = $att->getData('attribute_group_id');
$group = Mage::getModel('eav/entity_attribute_grou ...
jquery常用的js
- 博客分类:
- JS/Css
jQuery(function($){
//删除
$('input[name=del]').click(function(){
if( !confirm('确认删除吗?') ) return false;
if( $('input[name="wish_ids[]"]:checked').size()==0 ){
alert('请选择要删除的项');
return false;
}
});
//全选
$('input ...
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'attribute' => 'p_title',
'model'=>$model,
'name'=>'date',
'options' => array(
'showAnim' => 'fold',
'dateFormat' => 'yy-mm-d ...
Yii页面调转,提示信息存储
- 博客分类:
- PHP
【Control】
Yii::app()->user->setFlash('commentSubmitted ','显示跳转后的信息'); $this->redirect('list.m'); //页面跳转,list.m是因为写重写了router
【View】
<?php if(Yii::app()->user->hasFlash('commentSubmitted ')): ?> <div class="flash-success"> ...
首先在config文件中设置log
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning,t ...
yii 操作session
- 博客分类:
- PHP
在 Yii框架中使用session 的笔记:首先,在Yii框架中,你不需要像标准PHP代码那样使用session_start(),在Yii框架中,autoStart 属性缺省被设置为true,所以,
帅气的table表格
- 博客分类:
- JS/Css
.tb_02{
width: 950px;
border-collapse: collapse
}
.tb_02 td.w01 {
padding: 0;
text-align: center;
width: 113px;
}
.tb_02 td.w03 {
width: 141px;
}
.tb_02 td.w04 {
width: 141px;
}
.tb_02 td.w02 {
width: 141px;
}
.tb_02 td.w05 {
width: 141px;
}
.tb_02 td.w06 {
width: 216p ...
返回页面顶部js实现
- 博客分类:
- JS/Css
<a href="javascript:void(0);" id="toplink">返回页面顶部</a>
window.onload = function() {
if ($("#toplink")) {
$("#toplink").onclick = function() {
if (document.documentElement.scrollTop) {
document. ...
yii中引入js和css文件
- 博客分类:
- PHP
一、引入jquery核心部件
代码
Yii::app()->clientScript->registerCoreScript('jquery');
批注:不论在页面中的何种位置引用,最终yii会将jquery.js文件放入yii的assets文件夹下。即/projectName/assets/82qg58/jquery-1.6.1.min.js。
二、在控制器添加CSS文件或JavaScript文件
代码
public function init()
{
//parent::init(); ...
phpExcel 正确读取excel表格时间
- 博客分类:
- PHP
利用phpExcel读取excel文件,读取出来的时间列出现5位数字,并不是想要的时间(不知道为啥),在网上搜了一个excelTime的函数可以正确转化时间
error_reporting(E_ALL);
date_default_timezone_set('Asia/shanghai');
/** PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';
$inputFileName = '6081076641077444758.xls';
$objReader = new PHPExcel ...