php :: mysql
mysql_php 大全
<?php $con = mysql_connect("localhost", "root", "dami"); if(!$con) { die('不能连接到指定数据库'); } mysql_select_db("lesson", $con); //mysql_query("insert into student values(226,'书籍',26,'this is description')"); //mysql_query("update student set des = 'the des of joan' where id = 2"); //mysql_query("delete from student where id = 226"); $result = array(); $result_temp = mysql_query("select * from student"); while($row = mysql_fetch_array($result_temp)) $result[] = $row; //print_r($result); foreach($result as $index => $student) { echo "$index \n"; print_r($student); echo "\n"; } //var_dump($result); mysql_close($con); ?>
$con = mysql_connect("localhost", "root", "abc123"); //建立数据库连接
mysql_select_db("db_name", $con); //选择数据库
mysql_query("select * from student", $con); // 数据库查询
mysql_query("insert into student(id,name) values(2,'student_one_name')"); //插入数据
//mysql_query获取的数据处理
while($row = mysql_fetch_array($result))
$result[] = $row;
mysql_close($con); //数据库连接关闭
修改列属性默认值: alter table t_sap_account_history alter column check_status set default 0