向数据库里插入数据失败。大家看看是哪的事情

#1 aapill

我在向数据库里插入数据的时候失败,大家看一看是哪的问题,是不是ACTION写错了,下面是代码,
控制器代码!!
class customer_type extends spController{
   
    function add_distinct(){
        $this->display("add_distinct.html");
        }
    function add_type(){
        $add_type=spClass("customer_type");
        $add_type->create($this->spArgs());
    }
    function add_customer(){
      
        $this->display("add_customer.html");
    }
}

模板代码:





小区名称



我在查看源文件的时候ACTION显示
<form action="/customerinfo/index.php?c=customer_type&a=add_type" method="post" name="form1">
说明 一下customerinfo是我www根目录下的一个文件夹,所以东西存放在这个里面
请大家给予指导

2010-08-11 16:44:30

#2 aapill

alert('a')

2010-08-11 16:47:50

#3 jake

把上面的数据库模型类$add_type=spClass("customer_type");
改个名字,比如说叫lib_customer_type

2010-08-11 21:26:56

#4 aapill

jake还是不行呀,是怎么回子事呀!用SQL语句的方式能插入,也能取到值,只是一碰到CREATE就不行了

2010-08-11 21:39:20

#5 jake

在create之前先dump($this->spArgs()); 看看表单提交的值是什么?

另外在执行完create之后,也可以用 echo $add_type->dumpSql();来看看刚才执行的SQL是什么

2010-08-11 21:45:59

#6 aapill

回复 5 jake

表单传递过来的变量就是提交的变量,这个没有错,但是打印出来的最后的执行语句却是

    DESCRIBE customer_type;
jake 看看是怎么回子事?

2010-08-12 10:46:20

#7 jake

猜不出来是什么问题,提示太少了:lol

你再试试看 customer_type 这个名字是不是控制器和模型都有,重名了。或者表字段和提交上来的东西是不是一致。

2010-08-12 11:18:12

#8 aapill

jake 在你的提示下问题解决了,都是我的原因,闹了半天就是表单中的NAME和字段名称不一致造成的,感觉用框架开发就是很快哟,用最少的代码做最多的事情!

2010-08-12 11:33:22