Surance Center
posted @ 2009-04-30 22:52 xxp 阅读(3211) 评论(3) 编辑

文档:

 

sample enviroment:
it's not simle to yours but I think it will work.
windows server 2003 Simple Chinese edition
apache 2.2.11
php-5.2.8-Win32
MySQL-5.1.31
=============


0.编码选择:UTF-8 还是 GB2312还是GBK。
UTF-8可以兼容ASCII编码,会根据需要占用1个或者2个字节,比较小。(其他如UTF-16和UTF-32是固定死占用2个字节或者4个字节的)
GB2312只能包括6000多常用字
GBK可以包含简体、繁体,范围广

1. PHP中的设置
php中要对php.ini文件中设置开启extension=php_mbstring.dll,按照需要修改mb_string的相关编码配置
2.MySql中的设置:
因为mySql字符集的支持细化到四个层次: 服务器(server),数据库(database),数据表(table)和连接(connection)。因此可以后面再设置
3.Apache中的设置:
如果是UTF-8就不用设置,如果是GBK需要设置一下httpd.conf ,开启AddDefaultCharset
4.具体操作:
第一步:建立数据库
默认是latine的encoding和collection的。因为只有一个字段是中文的,所以不用修改数据库的默认配置文件。
只要建立数据库的时候,对这个字段设置为gbk_chinese_ci即可
第二步:设置网页的charset和encoding。如果是没有设置,将根据客户端的Request来
第三步,建立连接的时候需要
SET character_set_client='gbk'
SET character_set_connection='gbk'
SET character_set_results='gbk'
(这个配置就等价于 SET NAMES 'gbk'。


================================================

0.choose an encoding
you have 3 choises:utf-8,gb2312 and GBK.
UTF-8 contains ASKII, and it uses 1 or 2 bytes so it's smaller to transform in web.
but it's contains less Chinese Characters.(Others like UTF-16 and UTF-32,is fixed to user 2 or 4 bytes)
GB2312 contains only 6000 more popular characters, such as '朱镕基' can't be contained.
GBK contains simple Chinese and Tranditional Chinese ,I think it's pro. my sample is for GBK.


1. config PHP
modify php.ini , and set the line
extension=php_mbstring.dll
on
.maybe you need to configurate the mb_string.
2.mySql configration
as mySql supports defferent charset in 4 layers, the server, the database,the table and connection.
and you have only one table ,one field in Chinese, you need not to modify the whole mysql configration

3.Apache configuration
If you are willing to use UTF-8 , you need not to configurate anything for it support utf-8 by default.
if you want to use GBK you need to modify httpd.conf and open the AddDefaultCharset

4.sample steps:
firstly, create a database
and the database's collection is latine.
when you create the table, the field, set the field's collection to gbk_chinese_ci

secondly, set the special pages you want to show the Chinese Characters.
set the charset and encoding


third, when you build a connection ,either in commandline or php , you need to run the 3 lines script:

SET character_set_client='gbk'
SET character_set_connection='gbk'
SET character_set_results='gbk'

these three lines are equle to

 SET NAMES 'gbk'

 

 

 

例子:

 

php文件

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>测试中文入数据库</title>
</head>

<body>
<ul>
 <?php
 $conn = mysql_connect("localhost","root","sa");
mysql_query("set names 'gbk'");//关键是这句
mysql_select_db("test");
$sql = "select * from chinesetest ";
$result = mysql_query($sql,$conn);


while($row = mysql_fetch_assoc($result))
{
 echo  "<li>".$row['id']."-".$row["CF"]."</li>";
}

$sql2 = "Insert Into chinesetest (CF) values('中文插入测试');";
mysql_query($sql2);
$sql2 = "Insert Into chinesetest (CF) values('請看,這裡是繁體中文')";
//echo $sql2;
mysql_query($sql2);
echo mysql_error();

mysql_close();
?> 
</ul>
</body>
</html>
 整体解决方案:

/Files/xxpyeippx/chinese_on_mysql.zip

建表语句:

CREATE TABLE IF NOT EXISTS `chinesetest` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `CF` varchar(255) CHARACTER SET gbk NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

 

posted @ 2009-03-08 22:36 xxp 阅读(230) 评论(0) 编辑

asp.net中使用php常用的jquery等类库来实现ajax不是很容易。因为

asp.net的机制已经被封装了,依靠内部的viewstate,如果硬用js修改了控件的值,跟他的viewstate对不上,而这些控件又是不可修改的,将对程序造成安全性困扰,后台获取值也是一个麻烦。

另外,asp.net的控件也封装了html控件,使用js操作不是这么直接。

根据Surance( http://www.fltek.com.cn/)研究发现,在asp.net中,有3种方法使用ajax比较简单。算是ms的一个补偿方案来的。

一个是PageMethod,一个是使用ICallbackEventHandler,还有一个是用ms自带的ajax控件。

分别举例说明,

以下例子要实现的功能为:

在页面有一个div,一个按钮。点击按钮要调用后台方法获取一个时间,然后将时间写入div。要求页面不刷新

另外有个后台的按钮,点击此按钮,取到保存后的值

1.PageMehtod

第一步,建立一个asp.net的ajax网站(或者建立普通网站后修改webconfig)

第二步,在页面建立控件:

 <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />

 <div id="show" runat="server">aaaa
         </div>

  <asp:HiddenField ID="HiddenField1" runat="server" />

  <input type="button" value="1111" onclick="myFun()" id="Button2" />
        <asp:Button ID="Button1" runat="server" Text="getValue" OnClick="Button1_Click" />

 

第三步,js

 <script>
        function myFun()
        {
            PageMethods.GetDate('a',myCallBack)
        }
       
        function myCallBack(result)
        {
            var di = document.getElementById("HiddenField1");
            di.value=result;
            
 var di = document.getElementById("show");
            di.innerHTML=result;

 
        }
       
    </script>

 

第四步,后台代码

注意,这个方法必须是静态方法,必须是写入以下特性。

因此这个方法不可以直接访问页面的值

 [System.Web.Services.WebMethod]
    public static DateTime GetDate(string a)
    {

        return DateTime.Now;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
         DataTable dt = (DataTable)this.DataList1.DataSource;
         Response.Write(dt.Rows.Count);
    }

 

2.使用ICallbackEventHandler

第一步同上

第二步,页面实现接口

public partial class Default2 : System.Web.UI.Page, ICallbackEventHandler

第三步,建立控件

 

 <form id="form1" runat="server">
   
   
    <div id="show">
   

    </div>
    <input type="button" onclick="CallServer()" value="CallServer"></input>

 

第四步,

写入js

 <script type="text/javascript">
      function CallServer()
     {
         var product = "1";
         <%= ClientScript.GetCallbackEventReference(this, "product", "ReceiveServerData",null)%>;
     }
   
     function ReceiveServerData(rValue)
     {
        alert(rValue);
             var di = document.getElementById("show");
            di.innerHTML=rValue;
    }
 </script>

 

第五步,

后台代码

声明变量: public  string CallBackValue;

接口方法:

 public string GetCallbackResult()
    {
        return CallBackValue + ",ok";

    }

    public void RaiseCallbackEvent(string eventArgument)
    {
                       this.CallBackValue = eventArgument;
               


}

 

说明:RaiseCallbackEvent是实际做事的方法

GetCallbackResult是执行完动作回调的方法。

可以修改控件的值。

先执行后台的回调方法,后执行前台js的回调方法

可以使用RenderControl等类,来将asp.net控件输出为html

可以在RaiseCallbackEvent中switchargument,看看是什么地方传来的,以便调用不同的函数。

posted @ 2009-02-21 17:02 xxp 阅读(226) 评论(0) 编辑

原文地址:http://www.xoops.org/modules/mediawiki/index.php?title=Dev:search_function&curid=355&oldid=1067
注意:我是一个新的xoops开发者,请时刻留意这一点
记录一下我开发myguestBook模块时候学到的搜索功能
1. 第一,向xoops_version.php文件加入以下的代码

 Search $modversion['hasSearch'] = 1;
 $modversion['search']['file'] = "include/search.inc.php";
 $modversion['search']['func'] = "guestbook_search";
2.第二,按照以上的设定添加文件,并写代码:

 

=====

翻译者:Surance Yin  (Suranceyin@yahoo.com.cn)

©:http://www.fltek.com.cn

=====

 

 

 

Code
posted @ 2008-08-16 22:20 xxp 阅读(117) 评论(0) 编辑

标题:最轻量级的ORM(含实例)
下载地址:http://files.cnblogs.com/xxpyeippx/EasyDBOperationV3.0.rar
作者介绍:
Surance Yin
个人主页: www.fltek.com.cn
Cnblogs: www.cnblogs.com/xxpyieppx/
邮箱:suranceyin@yahoo.com.cn


基本信息:
类型:类库
协议:GPL
环境:.net framework 2.0
数据库:Sqlserver 2000/2005
最好配合CodeSurance一起使用


特性:
1.最轻量级的ORM。
2.实现了字符串过滤
3.支持分页(不需要存储过程)


升级记录(2.0-3.0)
增加了字符串过滤
增机阿拉分页支持

 

额外说明:
1.最好结合aspnetPager
2.ConsoleApplicationTest里面包含了使用范例


到底有多简单:
p.Add();
p.Edit();
manager3.Delete();
ProductInfo info = (ProductInfo)manager2.GetOne((object)id);


操作过程:
1.生成实体类(可以使用CodeSurance来生成)
2.继承CommonOperation,建立对操作类。(主要是要指定表名)
3.在客户端调用操作类即可。

posted @ 2008-05-25 20:27 xxp 阅读(1019) 评论(17) 编辑
摘要: XOOPS模块开发快速入门中文翻译(十) (4-19 10:17) XOOPS模块开发快速入门中文翻译(九) (4-19 10:10) XOOPS模块开发快速入门中文翻译(八) (4-19 09:37) XOOPS模块开发快速入门中文翻译(七)(4-18 18:42) XOOPS模块开发快速入门中文翻译(六) (4-17 22:40) XOOPS模块开发快速入门中文翻译(五) (4-17 21:4...阅读全文
posted @ 2008-04-19 10:20 xxp 阅读(646) 评论(0) 编辑
摘要: 由于这两天一直研究XOOPS的模块,所以找到了这篇很好的模块开发快速入门。看了以后,就兴致勃勃的来开发模块了,可是开发的过程中遇到一些问题。应该是我看的太快了,要学而时习之啊。因此翻译在这里。==============作者:Surance Yin邮箱:Suranceyin@yahoo.com.cn主页:http://www.fltek.com.cn=================第八章――数据...阅读全文
posted @ 2008-04-19 10:17 xxp 阅读(463) 评论(2) 编辑
摘要: 由于这两天一直研究XOOPS的模块,所以找到了这篇很好的模块开发快速入门。看了以后,就兴致勃勃的来开发模块了,可是开发的过程中遇到一些问题。应该是我看的太快了,要学而时习之啊。因此翻译在这里。==============作者:Surance Yin邮箱:Suranceyin@yahoo.com.cn主页:http://www.fltek.com.cn=================第四章――xo...阅读全文
posted @ 2008-04-19 10:10 xxp 阅读(610) 评论(1) 编辑
摘要: 由于这两天一直研究XOOPS的模块,所以找到了这篇很好的模块开发快速入门。看了以后,就兴致勃勃的来开发模块了,可是开发的过程中遇到一些问题。应该是我看的太快了,要学而时习之啊。因此翻译在这里。==============作者:Surance Yin邮箱:Suranceyin@yahoo.com.cn主页:http://www.fltek.com.cn=================第六步- 插入...阅读全文
posted @ 2008-04-19 09:37 xxp 阅读(553) 评论(1) 编辑
摘要: 由于这两天一直研究XOOPS的模块,所以找到了这篇很好的模块开发快速入门。看了以后,就兴致勃勃的来开发模块了,可是开发的过程中遇到一些问题。应该是我看的太快了,要学而时习之啊。因此翻译在这里。==============作者:Surance Yin邮箱:Suranceyin@yahoo.com.cn主页:http://www.fltek.com.cn=================第三章 ――建...阅读全文
posted @ 2008-04-18 18:42 xxp 阅读(565) 评论(1) 编辑
Surance Center