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服务器集群部署实现
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 ......
<?php
/*
* 名称 : MySQL数据库基本操作
* 作者 : pjx
* 版本 : v 2010/02/25 v 1.0
* 说明 : 该类用于对MySQL做一些简单的操作
* 示例 :
* 实例 => $db = new DB_MYSQL($database),打个$database数据库
* 查询数据库 => $db->query($sql_str),查询$sql_st ......
做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统。假设
id=1
的这本书库存为
1
,但是有
2
个人同时来借这本书,此处的逻辑为
Select restnum from book where id =1 ;
-- 如果 restnum 大于 0 ,执行 update
Update boo ......
PHP 存取 MySQL 乱码问题
上一篇 / 下一篇 2007-06-04 03:33:50 / 个人分类:PHP学习
查看( 239 ) / 评论( 0 ) / 评分( 0 / 0 )
MySQL 的字符集支持(Character Set Support)有两个方面:字符集(Character set)和排序方式(Collation)。对于字符集的支持细化到四个层次: 服务器(server),数据库(database),数据表 ......
http://incubator.apache.org/cassandra/
http://zh.wikipedia.org/wiki/Cassandra
Apache Cassandra是一套开源分布式数据库管理系统。它最初由Facebook开发,用于储存特别大的数据。
主要特性:
分布式
基于column的结构化
高伸展性
Cassandra的主要特点就是它不是一个数据库,而是由一堆数据库节点共同构成的一 ......