php连接mysql测试和配置
php连接mysql测试代码:
$link=mysql_connect('localhost','root','123456');
if(!$link) echo "失败!";
else echo "成功!";
mysql_close();
?>
运行代码出现:Call to undefined function 'mysql_connect()'… 失败
百度找到结果是PHP+MYSQL 环境没配置好, php5 的默认 mysql 是关闭的
将php_mysql.dll和libmysql.dll文件拷贝至c:\winnt\system32中(我漏了libmysql.dll)
找到php.ini中的;extension=php_mysql,去掉前面的";" 重启服务器.
相关文档:
最近写了一个简单的Mysql操作类,拿出来和大家分享一下,还请各位高手指正一下析构函数的用法:
<?php
/*
* Created on 2010-5-25
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*
* class mysql
* made by S71ENCE
*/
class mysql ......
做一些数据库查询,不仅希望得到要查询的结果,还希望方便地统计一下查询结果中有多少条记录。我通常的做法是:
$q = "select * from $fromTable where $where limit $start,$pageSize";
$r = mysql_query($q);
$q = "select count(*) from $fromTable where $where";
$cnt = mysql_query($q);
当 ......
JAVA调用MYSQL存储过程
工程视图:
代码清单:
myconn.java
package org.apache.sh_mysql.test;
import java.sql.*;
public class MyConn {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost/test?useUnicode=true&characterEn ......
设置字段的默认值:
创建表的时候:create table
tablename(columnname columntype default
defaultvalue);
修改表的时候:alter table
tablename alter column
columnname set
default
deflaultvalue; ......