主题:  请教mysql在windows的基本用法?

hemingp

职务:普通成员
等级:1
金币:0.0
发贴:106
注册:2001/11/9 23:10:35
#12001/11/27 14:12:47
谁有教程可以让我看看吗?就是基本的数据库建立,表、字段的设立的方法等等,
谢谢。



BLTF

职务:普通成员
等级:1
金币:0.0
发贴:20
注册:2000/12/12 21:49:45
#22001/11/27 21:48:56
记的网上有《MYSQL手册》和《MYSQL网络数据库指南》
不错。
不过,我看你先学好SQL。



5D荣誉斑竹

职务:普通成员
等级:2
金币:1.0
发贴:400
注册:2001/5/27 23:27:59
#32001/11/27 23:05:44
这里
www.webdevcn.com/document/view.php?id=278
www.webdevcn.com/document/view.php?id=365

这样的问题我至少在5d贴过3次,所以建议先搜索再提问



hemingp

职务:普通成员
等级:1
金币:0.0
发贴:106
注册:2001/11/9 23:10:35
#42001/12/9 17:17:54
呵呵,谢谢你!麻烦你了,我不是没有搜索过呀,只是找不到!



5DPHP版主

职务:版主
等级:2
金币:10.0
发贴:291
注册:2001/1/13 10:51:40
#52001/12/9 18:02:41
MYSQL其实很简单的,我建议你看看网上的电子书,然后再实践实践就行了



5DPHP版主

职务:版主
等级:2
金币:10.0
发贴:291
注册:2001/1/13 10:51:40
#62001/12/9 18:03:42
对了,另外我决的MYSQL在PHP里的函数挺不好记的,我觉得主要是这个比较难!



5D荣誉斑竹

职务:普通成员
等级:2
金币:1.0
发贴:400
注册:2001/5/27 23:27:59
#72001/12/9 21:39:16
feifan在上个帖子中说
引用:
对了,另外我决的MYSQL在PHP里的函数挺不好记的,我觉得主要是这个比较难!


把对数据库的操作封装在一个类里面就好了。



cheng527

职务:普通成员
等级:1
金币:0.0
发贴:35
注册:2001/10/18 9:56:29
#82001/12/10 9:14:57
felixding在上个帖子中说
引用:


把对数据库的操作封装在一个类里面就好了。

你说的是自己写一个类吗???



5D荣誉斑竹

职务:普通成员
等级:2
金币:1.0
发贴:400
注册:2001/5/27 23:27:59
#92001/12/10 12:03:46
cheng527在上个帖子中说
引用:
felixding在上个帖子中说
引用:


把对数据库的操作封装在一个类里面就好了。

你说的是自己写一个类吗???


可以自己写,也可以用phplib中的



BLTF

职务:普通成员
等级:1
金币:0.0
发贴:20
注册:2000/12/12 21:49:45
#102001/12/10 19:39:36
//Lee.Mars精心设计的DB类 Version 0.8.1 严禁修改^^

Class DB
{
    var $connect_id; //数据库连接号
    var $query_id; //mysql_query()返回的结果
    var $info; //read()返回的数据
    var $config; //数据库配置文件
    var $debug = True ; //调试模块

    var $stack = array() ; //数据堆栈 用于现场回复
    var $point = 0; //堆栈指针
    //DB类目前采用堆栈式存放法,不允许跳取

    function error($num) //错误处理模块
    {
        if ($this->debug)
            echo "出错模块:$mod_name
";

        echo "DB 错误: ";
        switch ($num)
        {
            case 0:
                echo "不能连接MYSQL";
                break;
            case 1:
                echo "不能使用数据库";
                break;
            case 2:
                echo "配置文件不存在或文件名为空";
                break;
            case 3:
                echo "不能关闭MYSQL连接";
                break;
            //支持错误号
            default:
                echo $num;
                break;
            //也支持字符串的错误信息
        }
        exit;
    }

    function DB($filename) //构造函数 设置配置文件
    {
        $this->mod_name = "DB"; //模块名,debug就靠他了

        if (file_exists($filename) == False || empty($filename) == True)
            //判断 1.文件是否存在 2.是否置空(因为空也算存在)
            $this->error(2); //输出错误信息
        else
            $this->config = $filename;
    }

    function connectdb() //连接MYSQL
    {
        $this->mod_name = "connectdb";
    
        include($this->config);     //包含配置文件(不能用require)

        $this->connect_id = @mysql_connect($DB_Host,$DB_User,$DB_Password) or $this->error(0); //进行连接

        @mysql_select_db($DB_Name,$this->connect_id) or $this->error(1); //可选
    }

    function query($query) //发送SQL请求
    {
        $this->mod_name = "query";

        $this->query_id = @mysql_query($query,$this->connect_id);
        if ($this->query_id == False)
            $this->error("ERROR ".mysql_errno().": ".mysql_error()."
"); //输出错误信息
    }
    
    function read()
    {
        $this->mod_name = "read";

        if (!$this->query_id)
            return False;

$this->info = @mysql_fetch_array($this->query_id); //读入$info中
     return is_array($this->info); //返回$info是否是数组 否就是读完了
    }

    function close() //关闭连接
    {
        $this->mod_name = "close";

        @mysql_close($this->connect_id) or $this->error(3);
    }

    function save() //保存现场
    {
        $this->mod_name = "save";

        $this->point++;
        $this->stack[$this->point][query_id] = $this->query_id;
        $this->stack[$this->point][info] = $this->info;
    }

    function load() //读入现场
    {
        $this->mod_name = "load";
        if (!$this->point)
            return False;

        $this->query_id = $this->stack[$this->point][query_id];
        $this->info = $this->stack[$this->point][info];
        $this->point--;
    }
}

$DB = New DB("DBconfig.inc.php");
?>



hemingp

职务:普通成员
等级:1
金币:0.0
发贴:106
注册:2001/11/9 23:10:35
#112001/12/10 21:18:06
对了, 导入.txt格式的数据时, 数据文件要放哪啊? 怎么我导入时提示说找不到?



BLTF

职务:普通成员
等级:1
金币:0.0
发贴:20
注册:2000/12/12 21:49:45
#122001/12/11 18:35:38
导入TXT文件?
能直接导入的好象是PHP和INC吧~~
用相对路径~~~



vital

职务:普通成员
等级:1
金币:10.0
发贴:194
注册:2001/5/15 12:10:20
#132001/12/12 9:30:17
应该可以倒入任何扩展名的以文本形式储存的文件。