空地

生活,工作,记录(内容基本都是转载,自己工作用到的时候看看而已)

2010年9月1日 #

ZendStudio 6.0.1 升级时 RSE 错误的问题

ZendStudio 6.0.1 在线升级的时候会出现如下错误:

When performing new features (plug-ins) installation the following message may appear in the Search Results dialog:RSE Feature Patch (3.0.2.v20090119-1307w311_122_) requires feature "org.eclipse.rse"

解决办法为http://www.zend.com/en/support/knowledgebase.php?kbid=356&view_only=1,其实就是需要安装RSE相关的一些包。

转载如下:

  1. In Zend Studio for Eclipse, go to Help | Software Updates | Find and Install... ZendStudioRse
  2. In the Feature Updates dialog, select the second option Search for new features to install and click Next ZendStudioRse
  3. In the Update sites to visit dialog, select the Target Management Updates and click Finish ZendStudioRse

    Note: You may want to check the Automatically select mirrors checkbox before clicking Finish, in order to skip the mirror selection prompt

    ZendStudioRse

  4. In the Search Results dialog, uncheck the Show the latest version of a feature only checkbox

    Open the hierarchy Target Management Updates | TM and RSE 3.0.2 Mark the first three plug-ins, namely:

    • Remote System Explorer Core 3.0.2.v200812041720-7Z37BEB7sQS9UkXMIjJI
    • RSE DStore Services 3.0.2.v200812041720-7J35DUUEFDHoHxAT97
    • Remote System Explorer End-User Runtime 3.0.2.v200812041720-7H3788qfeqHMeUOEQ2IKjVLIiQ8

    ZendStudioRse 注:这里需要注意,由于选中了显示最新的软件包,可能需要的版本没有出现。这就需要取消最新版本那个选项,然后选择出现错误所需要的那个版本即可。

  5. Click Next and complete the installation by accepting the defaults in the dialogs to follow
  6. Restart Zend Studio for Eclipse

posted @ 2010-09-01 13:55 小梅 阅读(21) 评论(0) 编辑

2010年8月31日 #

python mysql 数据库交互

1.确认 已经安装了 MySQLdb module 

Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import MySQLdb Traceback (innermost last): File "<stdin>", line 1, in ? ImportError: No module named MySQLdb >>>
这样的消息说明没有安装MySQLdb, 从http://sourceforge.net/projects/mysql-python下载安装。

$ tar -xzvf MySQL-python-0.9.2.tar.gz
$ cd MySQL-python-0.9.2
$ python setup.py build
$ python setup.py install

再检查:


Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import MySQLdb >>>


然后我们用以下这个数据表:



mysql> SELECT * FROM animals; +---------+----------+ | name | species | +---------+----------+ | Wallace | Walrus | | Polly | Parrot | | Freddie | Frog | | Tusker | Elephant | | Sammy | Skunk | +---------+----------+ 5 rows in set (0.01 sec)
然后用这个短小的python 代码,检索并打印出每条记录

#!/usr/bin/python # import MySQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("SELECT * FROM animals") # get the resultset as a tuple result = cursor.fetchall() # iterate through resultset for record in result: print record[0] , "-->", record[1]
然后我们一步一步认识下这个过程,先是 python 导入 MySQLdb module

# import MySQL module import MySQLdb
之后打开一个数据库连接,需要参数 服务器,用户名,密码,数据库名

# connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a")
成功连接后可以得到一个db对象,可以生成游标

# create a cursor cursor = db.cursor()
这个游标用于执行SQL,并返回得到的结果

# execute SQL statement cursor.execute("SELECT * FROM animals") # get the resultset as a tuple result = cursor.fetchall()
有很多种方法去获得这个SQL 结果,这里使用的是fetchall(),他会返回一个元祖集,它里面的每一个元祖表示一行数据,可以用for进行循环显示每一个数据。
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
也可以用fetchone()每次去获取一条数据,看下面的例子:
#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="joe", passwd="secret",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM animals")
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
# get and display one row at a time
for x in range(0,numrows):
row = cursor.fetchone()
print row[0], "-->", row[1]
这里,我们先用游标的rowcount ()方法去获取结果集的条数。然后用在for循环中,去用fetchone()方法去获取每行数据。
我们还可以用fetchmany()方法去指定获取的条数。

#!/usr/bin/python # import MySQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("SELECT * FROM animals") # limit the resultset to 3 items result = cursor.fetchmany(3) # iterate through resultset for record in result: print record[0] , "-->", record[1]

很明显的,你可以执行 插入,更新 和 删除通过 MySQLdb  module 

 

#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="joe", passwd="secret",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("""INSERT INTO animals (name, species) VALUES ("Harry",
"Hamster")""")
修改一下,我们让用户输入信息,保存到数据库

#!/usr/bin/python # import MySQL module import MySQLdb # get user input name = raw_input("Please enter a name: ") species = raw_input("Please enter a species: ") # connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("INSERT INTO animals (name, species) VALUES (%s, %s)", (name, species))
这次运行的时候,你需要输入信息:

Please enter a name: Rollo Please enter a species: Rat

注意%s位置 会被 (name,species)元组的值 替换。

 

如果你有自动增长的字段,你可以使用insert_id()去获取最后一条插入的数据的ID。 



#!/usr/bin/python # import MySQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("""INSERT INTO test (field1, field2) VALUES ("val1", "val2")""") # get ID of last inserted record print "ID of inserted record is ", int(cursor.insert_id())

许多数据库脚本涉及到多次的数据操作(比如插入),每次插入大量的不同的值,MySQLdb有一个executemany()方法,可以简化这种操作。 

看下面的例子:


#!/usr/bin/python # import SQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="joe", passwd="secret", db="db56a") # create a cursor cursor = db.cursor() # dynamically generate SQL statements from list cursor.executemany("INSERT INTO animals (name, species) VALUES (%s, %s)", [ ('Rollo', 'Rat'), ('Dudley', 'Dolphin'), ('Mark', 'Marmoset') ])

这里,同样的操作被执行了很多遍(不同的值),通过传递给executemany()一个Python list,每个元素是一个元组。 

用这种方式,我们可以让用户一次输入大量的数据,然后一次性保存。


#!/usr/bin/python
# import MySQL module
import MySQLdb
# initialize some variables
name = ""
data = []
# loop and ask for user input
while (1):
name = raw_input("Please enter a name (EOF to end): ")
if name == "EOF":
break
species = raw_input("Please enter a species: ")
# put user input into a tuple
tuple = (name, species)
# and append to data[] list
data.append(tuple)
# connect
db = MySQLdb.connect(host="localhost", user="joe", passwd="secret",
db="db56a")
# create a cursor
cursor = db.cursor()
# dynamically generate SQL statements from data[] list
cursor.executemany("INSERT INTO animals (name, species) VALUES (%s,
%s)",
data)

这里我们用while 循环让用户输入信息,保存到values 列表,当用户输入完成的时候,执行executemany() 

 

MySQLdb 类还有很多其他有用的方法 :

 

connection.begin() - 开始一个事务

connection.apilevel() - returns the current DB APIlevel

connection.conv() - set type conversion options between MySQL and Python

connection.commit() - commit a transaction

connection.rollback() - roll back a transaction

有用的链接:

The MySQLdb project page on SourceForge, athttp://sourceforge.net/projects/mysql-python

The Python home page, at http://www.python.org/

The MySQL home page, at http://www.mysql.com/



Note: All examples in this article have been tested on Linux/i586 with Python 1.5.2, MySQL 3.23 and MySQLdb 0.9.2. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!

posted @ 2010-08-31 21:57 小梅 阅读(207) 评论(0) 编辑

2008年2月2日 #

交叉表 查询 例子(Sql Server 2005)

use db_student
select * from sp pivot(sum(销售数量) for 商品名称 in ([李专辑],[张专辑]))) as 统计

select 商品名称,a.[9] as [九月],a.[10] as [十月],a.[11] as [十一月],a.[12] as [十二月] from sp pivot(sum(销售数量) for 月份 in([9],[10],[11],[12])) as a

posted @ 2008-02-02 20:52 小梅 阅读(868) 评论(0) 编辑

2006年11月9日 #

showModalDialog()、showModelessDialog()方法使用详解(转载)

 

showModalDialog()、showModelessDialog()方法使用详解

 Javascript有许多内建的方法来产生对话框,如:window.alert(), window.confirm(),window.prompt().等。 然而IE提供更多的方法支持对话框。如:

  showModalDialog() (IE 4+ 支持)
  showModelessDialog() (IE 5+ 支持)


 window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框,由于是对话框,因此它并没有一般用window.open()打开的窗口的所有属性。
 window.showModelessDialog()方法用来创建一个显示HTML内容的非模态对话框。

 当我们用showModelessDialog()打开窗口时,不必用window.close()去关闭它,当以非模态方式[IE5]打开时, 打开对话框的窗口仍可以进行其他的操作,即对话框不总是最上面的焦点,当打开它的窗口URL改变时,它自动关闭。而模态[IE4]方式的对话框始终有焦点(焦点不可移走,直到它关闭)。模态对话框和打开它的窗口相联系,因此我们打开另外的窗口时,他们的链接关系依然保存,并且隐藏在活动窗口的下面。

使用方法如下:
 vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
 vReturnValue = window.showModelessDialog(sURL [, vArguments] [, sFeatures])
参数说明:
 sURL
 必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
 vArguments
 可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
 sFeatures
 可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。
  dialogHeight 对话框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默认的单位是em,而IE5中是px,为方便其见,在定义modal方式的对话框时,用px做单位。
   dialogWidth: 对话框宽度。
   dialogLeft: 距离桌面左的距离。
   dialogTop: 离桌面上的距离。
   center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。
   help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes。
   resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no。
   status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
  scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。

  还有几个属性是用在HTA中的,在一般的网页中一般不使用。
  dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no。
  edge:{ sunken | raised }:指明对话框的边框样式。默认为raised。
  unadorned:{ yes | no | 1 | 0 | on | off }:默认为no。

 传入参数:
 要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如:

 test1.htm
 ====================
 <script>
  var mxh1 = new Array("mxh","net_lover","孟子E章")
  var mxh2 = window.open("about:blank","window_mxh")
  // 向对话框传递数组
  window.showModalDialog("test2.htm",mxh1)
  // 向对话框传递window对象
  window.showModalDialog("test3.htm",mxh2)
 </script>

 test2.htm
 ====================
 <script>
  var a = window.dialogArguments
  alert("您传递的参数为:" + a)
 </script>

 test3.htm
 ====================
 <script>
  var a = window.dialogArguments
  alert("您传递的参数为window对象,名称:" + a.name)
 </script>

 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:

 test4.htm
 ===================
 <script>
  var a = window.showModalDialog("test5.htm")
  for(i=0;i<a.length;i++) alert(a[i])
 </script>

 test5.htm
 ===================
 <script>
 function sendTo()
 {
  var a=new Array("a","b")
  window.returnValue = a
  window.close()
 }
 </script>
 <body>
 <form>
  <input value="返回" type=button onclick="sendTo()">
 </form>

 常见问题:
 1,如何在模态对话框中进行提交而不新开窗口?
 如果你 的 浏览器是IE5.5+,可以在对话框中使用带name属性的iframe,提交时可以制定target为该iframe的name。对于IE4+,你可以用高度为0的frame来作:例子,

 test6.htm
 ===================
 <script>
  window.showModalDialog("test7.htm")
 </script>

 test7.htm
 ===================
 if(window.location.search) alert(window.location.search)
 <frameset rows="0,*">
  <frame src="about:blank">
  <frame src="test8.htm">
 </frameset>

 test8.htm
 ===================
 <form target="_self" method="get">
 <input name=txt value="test">
 <input type=submit>
 </form>
 <script>
 if(window.location.search) alert(window.location.search)
 </script>
 2,可以通过http://servername/virtualdirname/test.htm?name=mxh方式直接向对话框传递参数吗?
 答案是不能。但在frame里是可以的。


作者Blog:http://blog.csdn.net/net_lover/

posted @ 2006-11-09 17:31 小梅 阅读(154) 评论(0) 编辑

表结构的复制方法

已有一DataTable类的tb1,其结构(包括字段、约束等)已知。  
  现定义  
  DataTable   tb2   =   new   DataTable();  
  如何把tb1的结构复制到tb2中?  


DataTable   tb2   =tb1.Clone();

posted @ 2006-11-09 17:15 小梅 阅读(116) 评论(2) 编辑

今天发现的东西

http://atlas.cnblogs.com/

http://www.cnblogs.com/ddr888/archive/2006/10/21/535500.html

http://www.cnblogs.com/JeffreyZhao/default.aspx?opt=msg

posted @ 2006-11-09 11:02 小梅 阅读(42) 评论(0) 编辑