<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Li Yue [学习笔记] &#187; mysql</title>
	<atom:link href="http://www.liyue.org/tech/archives/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.liyue.org/tech</link>
	<description>技术笔记</description>
	<lastBuildDate>Sun, 18 Jul 2010 02:14:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>数据复活</title>
		<link>http://www.liyue.org/tech/archives/167</link>
		<comments>http://www.liyue.org/tech/archives/167#comments</comments>
		<pubDate>Fri, 10 Apr 2009 04:59:01 +0000</pubDate>
		<dc:creator>李悦</dc:creator>
				<category><![CDATA[系统]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.liyue.org/tech/?p=167</guid>
		<description><![CDATA[　　某个系统管理员一不小心直接用数据库管理工具把一文章表的标题字段类型改了，导致所有文章标题不能正常显示了。上万条的数据有点懵了。之前数据库也没有备份过。试图修复数据库也没有成功。唯一的希望寄托在数据库本身的结构上。
　　由于文章的部分信息在另外一个表中也有所体现，标题信息正在其中。只要将这部分信息重写回表中就可以恢复。两个表是通过ID相关联的。检索出文章对应的标题并写回原表。但是原表文章范围大于另一个表，只要少量信息不存在。能恢复大部分信息就好了。

&#60;?php
$DB_Server = &#34;localhost&#34;;
$DB_Username = &#34;root&#34;;
$DB_Password = &#34;password&#34;;
$DB_DBName = &#34;dbname&#34;;
//$DB_TBLName = &#34;column_article&#34;;
$Connect = @mysql_connect&#40;$DB_Server, $DB_Username, $DB_Password&#41;
or die&#40;&#34;Couldn't connect.&#34;&#41;;
$Db = @mysql_select_db&#40;$DB_DBName, $Connect&#41;
or die&#40;&#34;Couldn't select database.&#34;&#41;;
&#160;
$sql = &#34;Select column_article.title,column_article.articleid,article.title,article.id from column_article,article where column_article.articleid=article.id&#34;;
$ALT_Db = @mysql_select_db&#40;$DB_DBName, $Connect&#41;
or die&#40;&#34;Couldn't select database&#34;&#41;;
&#160;
$result = @mysql_query&#40;$sql,$Connect&#41;
or die&#40;mysql_error&#40;&#41;&#41;;
&#160;
$i = 0;
while&#40;$row = mysql_fetch_row&#40;$result&#41;&#41;
&#123;
$title2=$row&#91;0&#93;;
$title2id=$row&#91;1&#93;;
$upd = @mysql_query&#40;&#34;update article set article.title='$title2' where article.id=$title2id&#34;,$Connect&#41;;
$i++;
&#125;
return &#40;true&#41;;
?&#62;

]]></description>
		<wfw:commentRss>http://www.liyue.org/tech/archives/167/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>将mysql检索结果导出EXCEL表</title>
		<link>http://www.liyue.org/tech/archives/94</link>
		<comments>http://www.liyue.org/tech/archives/94#comments</comments>
		<pubDate>Fri, 05 Dec 2008 03:18:19 +0000</pubDate>
		<dc:creator>李悦</dc:creator>
				<category><![CDATA[系统]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.liyue.org/tech/?p=94</guid>
		<description><![CDATA[说明：数据表fawen是文件的标题，正文等信息，数据表pishi是各领导对文件的批示信息，pishi的articleid字段内容与fawen的id相关联。要统计出某位领导的所有批示，导出EXCEL，内容是：文件名称、批示内容、批示时间。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
&#60;?php
$DB_Server = &#34;localhost&#34;;
$DB_Username = &#34;root&#34;;
$DB_Password = &#34;pass&#34;;
$DB_DBName = &#34;office&#34;;
$DB_TBLName = &#34;fawen&#34;;
$Connect = @mysql_connect&#40;$DB_Server, $DB_Username, $DB_Password&#41;
or die&#40;&#34;Couldn't connect.&#34;&#41;;
$Db = @mysql_select_db&#40;$DB_DBName, $Connect&#41;
or die&#40;&#34;Couldn't select database.&#34;&#41;;
$file_type = &#34;vnd.ms-excel&#34;;
$file_ending = &#34;xls&#34;;
header&#40;&#34;Content-Type: application/$file_type&#34;&#41;;
header&#40;&#34;Content-Disposition: attachment; filename=mydowns.$file_ending&#34;&#41;;
header&#40;&#34;Pragma: no-cache&#34;&#41;;
header&#40;&#34;Expires: 0&#34;&#41;;
$now_date = date&#40;'Y-m-d H:i'&#41;;
$title = &#34;格式：第一列为文件名，第二列为领导批示内容，第三列为批示日期&#34;;
$sql = &#34;Select $DB_TBLName.title,pishi.content,pishi.time from $DB_TBLName,pishi where pishi.leadername='领导名称' and $DB_TBLName.id=pishi.articleid&#34;;
$ALT_Db = @mysql_select_db&#40;$DB_DBName, $Connect&#41;
or die&#40;&#34;Couldn't select database&#34;&#41;;
&#160;
&#160;
$result = @mysql_query&#40;$sql,$Connect&#41;
or die&#40;mysql_error&#40;&#41;&#41;;
&#160;
$result2 [...]]]></description>
		<wfw:commentRss>http://www.liyue.org/tech/archives/94/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>数组的应用</title>
		<link>http://www.liyue.org/tech/archives/85</link>
		<comments>http://www.liyue.org/tech/archives/85#comments</comments>
		<pubDate>Mon, 20 Oct 2008 08:44:40 +0000</pubDate>
		<dc:creator>李悦</dc:creator>
				<category><![CDATA[系统]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.liyue.org/tech/?p=85</guid>
		<description><![CDATA[　　对已知数目的查询条件，使用数组定义，然后遍历数组，使用while循环查询符合数组数值条件的记录，并统计。
　　片段：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
		//数组
		$workArray = array&#40;&#34;办公室&#34;, &#34;财务基建&#34;, &#34;人事处&#34;, &#34;老干部处&#34;, &#34;机关党委&#34;,&#34;纪检监察&#34;,&#34;综合处&#34;,&#34;核算处&#34;,&#34;政法处&#34;,&#34;工业处&#34;,&#34;能源处&#34;,&#34;农村处&#34;,&#34;国贸处&#34;,&#34;外经处&#34;,&#34;投资处&#34;,&#34;服务业处&#34;,&#34;人口处&#34;,&#34;社科处&#34;,&#34;普查中心&#34;,&#34;基普办&#34;,&#34;科研所&#34;,&#34;计算中心&#34;,&#34;教育中心&#34;,&#34;记者站&#34;,&#34;印刷厂&#34;&#41;; 
&#160;
			while  &#40;list&#40;$key,$value&#41; = each&#40;$workArray&#41;&#41;  &#123;
				$z--;
				$sql5=&#34;select count(id) as id from art where author='$value' and createdate&#62;='$starttime' and createdate &#60;='$endtime'&#34;;
				$r5= $DB_web-&#62;query_first&#40;$sql5&#41;;
&#160;
				print &#34;&#60;tr bgcolor='#DDDDDD'&#62;&#34;;
				print &#34;&#60;td height='20'&#62;&#38;nbsp;$value&#60;/td&#62;&#34;;
				print &#34;&#60;td height='20'&#62;&#38;nbsp;$r5[id]&#60;/td&#62;&#34;;
　　　　　　　　print &#34;&#60;/tr&#62;&#34;;
&#160;
			&#125;

]]></description>
		<wfw:commentRss>http://www.liyue.org/tech/archives/85/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql最大连接数</title>
		<link>http://www.liyue.org/tech/archives/25</link>
		<comments>http://www.liyue.org/tech/archives/25#comments</comments>
		<pubDate>Thu, 07 Aug 2008 14:11:22 +0000</pubDate>
		<dc:creator>李悦</dc:creator>
				<category><![CDATA[系统]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.liyue.org/tech/?p=25</guid>
		<description><![CDATA[　　在linux下修改mysql最大连接数，网上说修改/etc/my.cnf文件。在[mysqld]段加入 max_connections =1000一行参数。结果导致启动失败。后来改成set-variable   = max_connections =1000成功。
　　还有将/etc/my.cnf权限改成644。
]]></description>
		<wfw:commentRss>http://www.liyue.org/tech/archives/25/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
