MySQL多表同时插入
Real example:
/*************************by garcon1986*********************************************************/
<?php
// get the values from entreprise creation form
$secteur = $_POST['secteur'];
$nom = $_POST['nom_entreprise'];
$taille = $_POST['taille_entreprise'];
$concurrent = $_POST['concurrent_entreprise'];
$investisseur = $_POST['investisseur_entreprise'];
$partenaire = $_POST['partenaire_entreprise'];
$client = $_POST['client_entreprise'];
$fournisseur = $_POST['fournisseur_entreprise'];
$info_general = $_POST['information_generale'];
//connection
//include("./conn/connect.php");
$conn = mysql_connect("localhost","charles","charles") or die("connection failed: ".mysql_error());
mysql_select_db("crm") or die("select db failed: ".mysql_error());
//execution - using trasaction
mysql_query('START TRANSACTION',$conn) or die(mysql_error());
mysql_query("insert into entreprise(nom, nombre_salarie, secteur, info_general) values('".$nom."','".$taille."','".$secteur."','".$info_general."')",$conn) or die(mysql_error());
$id = mysql_insert_id($conn) or die(mysql_error());
mysql_query("insert into concurrent(entreprise_id, nom) values('".$id."', '".$concurrent."')",$conn) or die(mysql_error());
mysql_query("insert into investisseur(entreprise_id, nom) values('".$id."', '".$investisseur."')",$conn) or die(mysql_error());
mysql_query("insert into partenaire(entreprise_id, nom) values('".$id."', '".$partenaire."')",$conn) or die(mysql_error());
mysql_query("insert into client(entreprise_id, nom) values('".$id."', '".$client."')",$conn) or die(mysql_error());
mysql_query("insert into fournisseur(entreprise_id, nom) values('".$id."', '".$fournisseur."')",$conn) or die(mysql_error())
相关文档:
关于分页的优化。
我们知道,在MySQL中分页很简单,直接LIMIT page_no,page_total 就可以了。
可是当记录数慢慢增大时,她就不那么好使了。
这里我们创建摘要表来记录页码和原表之间的关联。
下面为测试数据。
原表:
CREATE TABLE `t_group` (
`id` int(11) NOT NULL auto_increment,
`money` decim ......
具有负载均衡功能MySQL服务器集群部署实现
http://www.realure.cn/2009_241.html
http://www.realure.cn/2009_242.html
http://www.realure.cn/2009_243.html
http://www.realure.cn/2009_244.html
http://www.realure.cn/2009_245.html ......
做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统。假设
id=1
的这本书库存为
1
,但是有
2
个人同时来借这本书,此处的逻辑为
Select restnum from book where id =1 ;
-- 如果 restnum 大于 0 ,执行 update
Update boo ......
初学mysql我也碰到中文存储的问题,以下是我的解决方案:
1.首先在字段选项column option 中将字段字符集column charset设为gb2312。
2.还需要在表选项table option 中同样将charset设置为gb2312.
3.最后如果还不行,就在mysql安装目录下找到my.ini,找到以下位置:
[mysql]
default-cha ......
这时间在安装PHPBB的论坛,发现一个问题,那就是输入用户名跟密码后,点击安装,总是报了以下的错误:
程序代码
ORA-28008: invalid old password
Cause: old password supplied is wrong; Hence user cannot be authenticated using old password
Action: Supply the correct old password for authenticatio ......