三月 14, 2012
1.导出整个数据库 mysqldump -u 用户名 -p –default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql 2.导出一个表 mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名 mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql 3.导出一个数据库结构 mysqldump -u wcnc -p -d –add-drop-table smgp_apps_wcnc >d:wcnc_db.sql -d 没有数据 –add-drop-table 在每个create语句之前增加一个drop table 4.导入数据库 A:常用source 命令 进入mysql数据库控制台, 如mysql -u root -p mysql>use 数据库 [...]
tags: mysql操作命令
posted in ubuntu知识积累 by Allen yang | No Comments
二月 29, 2012
php升级为5.3后,程序会报 Function split() is deprecated 的错误。 这是因为种种原因(主要是关于正则的原因,具体见后),split这个函数在新版本不支持了。 在php中,再使用deprecated的函数会报错,必须改掉。(java里deprecated的函数只是给警告,还可以继续用) 改为什么呢? 看第一个参数,如果第一个参数不是正则表达式,split改为 explode;如果是正则表达式,split改为preg_split。 explode会比以前快很多,因为以前要考虑正则,explode不考虑正则。 所以将split() 替换成explode()就行了 其他替换的函数共参考: Differences from POSIX regex * POSIX → PCRE * ereg_replace() → preg_replace() * ereg() → preg_match() * eregi_replace() → preg_replace() * eregi() → preg_match() * split() → preg_split() * spliti() → preg_split() * sql_regcase() → No equivalent * 需要 regex [...]
posted in php知识积累 by Allen yang | No Comments
二月 28, 2012
我看ci的.htaccess中, rewritecond $1!^(index\.php|, 有些疑惑,这个$1代表的是什么呢?是rewriterule中的 ^(.*)$ 这里的(.*)吗? 看起来应该是的,但如果是的话,我记得正则表达式不是只有后向引用吗? 怎么rewritecond就可以引用rewriterule里的分组了呢?这还是后向引用吗? SORRY,找到答案了:Regex Back-Reference Availability One important thing here has to be remembered: Whenever you use parentheses in Pattern or in one of the CondPattern, back-references are internally created which can be used with the strings $N and %N (see below). These are available for creating the strings Substitution and [...]
posted in php知识积累 by Allen yang | No Comments
二月 24, 2012
创建和存储 cookie function setCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ “=” +escape(value)+ ((expiredays==null) ? “” : “;expires=”+exdate.toGMTString()) } 上面这个函数中的参数存有 cookie 的名称、值以及过期天数。 在上面的函数中,我们首先将天数转换为有效的日期,然后,我们将 cookie 名称、值及其过期日期存入 document.cookie 对象。 之后,我们要创建另一个函数来检查是否已设置 cookie: function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + “=”) if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(“;”,c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return “” } 上面的函数首先会检查 [...]
tags: cookie, js设置cookie
posted in js和jquery积累 by Allen yang | No Comments
二月 20, 2012
1.进入exif扩展库目录 引用 #cd /usr/local/src/php-5.2.6/ext/exif 2.调用phpize程序生成编译配置文件(如果不在扩展库目录下执行phpize命令会报错!i) 引用 [root@localhost exif]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519 3. 编译扩展库,分别执行下面的configure和make命令 引用 #./configure –with-php-config=/usr/local/php4/bin/php-config && make 4.配置php.ini 引用 # cp ext/exif/modules/exif.so /usr/local/apache2/modules/ #vim /usr/local/php/lib/php.ini 在php.ini文件中找到设置扩展目录的位置,然后将扩展路径设置到apache2 modules目录下 引用 extension_dir=”/usr/local/apache2/modules/” extension=exif.so 5.重启apache,查看phpinfo信息,即可看到刚才添加进去的exif扩展库.
tags: exif, exif扩展库
posted in php知识积累, ubuntu知识积累 by Allen yang | No Comments
二月 11, 2012
在magento中修改顶部链接toplinks 在magento 默认模板里面的顶部链接toplinks 在前台显示为 * My Account * My Wishlist * My Cart * Checkout * Log In 那么如何把它们修改成自己想要的链接呢?下面提供一个比较简单的方法: 首先你必须找到文件header.phtml 它在默认模板里的路径为www/app/design/frontend/default/default/template/page/html/header.phtml 修改时注意替换default为你的模板路径 找到打开编辑,在大概31行处你会看到一行代码 < ?php echo $this->getChildHtml(‘topLinks’) ?> 把它直接替换成你要修改的链接,用php语言写成 <li><a href=”<?php echo $this->getUrl(‘/customer/account/’) ?>” title=”MY ACCOUNT”>MY ACCOUNT</a></li> <li><a href=”<?php echo $this->getUrl(‘/yourlinksurl’) ?>” title=”YOUR LINKS”>YOUR LINKS</a></li> <li><a href=”<?php echo $this->getUrl(‘/customer/account/login/’) ?>” title=”LOG IN”>LOG IN</a></li>
posted in magento by Allen yang | No Comments
二月 11, 2012
1 在app/design/frontend/default/你的模板/template/创建目录directory,并在这个directory目录下面建一个phtml文件,名字为currency.phtml,内容如下: <?php if($this->getCurrencyCount()>1): ?> <div> <div> <?php echo $this->__(‘ Currencies:’) ?> <select name=”currency” title=”<?php echo $this->__(‘Select Your Currency’) ?>” onchange=”setLocation(this.value)”> <?php foreach ($this->getCurrencies() as $_code => $_name): ?> <option value=”<?php echo $this->getSwitchCurrencyUrl($_code) ?>”<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected=”selected”<?php endif; ?>> <?php echo $_name ?> – <?php echo $_code ?> [...]
posted in magento by Allen yang | No Comments
一月 19, 2012
可以应用设计模式的位置 1. 数据连接池,singleton/factory/flyweight (Hibernate 完成) 2. 多持久层方案选择,proxy / strategy(Hibernate 完成) 3. 参与者用例管理者 xxxManager instance, singleton 4. 架构服务 allService, facade/singleton 5. 权限, factory, proxy, visitor 6. 分页查询,proxy/iterator (Hibernate 完成) 7. 匹配搜索,同上(Hibernate Critiera Example 完成) 8. 状态更新通知、短消息,Observer 9. 栏目、文章 属性统计,Composite
tags: 新闻系统, 设计模式
posted in php知识积累 by Allen yang | No Comments
一月 19, 2012
简介: 设计模式只是为 Java™ 架构师准备的 —— 至少您可能一直这样认为。实际上,设计模式对于每个人都非常有用。如果这些工具不是 “架构太空人” 的专利,那么它们又是什么?为什么说它们在 PHP 应用程序中非常有用?本文解释了这些问题。
tags: php设计模式
posted in php知识积累 by Allen yang | No Comments
一月 19, 2012
<?php $IP = $_SERVER['REMOTE_ADDR']; $from = strcmp($IP,’192.168.0.0′); $to = strcmp($IP,’192.168.0.255′); if (!($from >= 0 && $to <= 0)) echo “Access Denied”; else echo “Homepage”; ?> Strcmp()函数对两个字符串进行二进制安全的比较,并区分大小写。 <?php echo strcmp(“Hello world!”,”Hello world!”); //返回0 ?> 简单的补充: 这里的str1和str2比较 实际上是str1和str2 的ASCII值的比较 比如: strcmp(“A”,”a”); 返回值为 -1 // a的ASCII值是97 A的ASCII值是65 由此例子还可以看出 当用strcmp()比较字符串时,是区分大小写的 接着再看strcmp的深入理解: strcmp(“abc”,”abc”); 此时 字符串相等 返回值为 0 [...]
tags: strcmp
posted in php知识积累 by Allen yang | No Comments