发新话题
打印

adodb如何取得ID值

本主题由 admin 于 2007-11-4 12:02 移动

adodb如何取得ID值

向表里面加入一个记录,如何取得刚插入记录的值 ?
复制内容到剪贴板
代码:
try
        {
            $rs = $this->db->CacheExecute (0, $this->sqlusr);
            
            $record = array();
            $record['nameft'] = $nameft;
            $record['secname']= $secname;
            $record['gander'] = "sex[".$gander."]";
            $record['email'] = $email;
            $record['security_qu'] = $question;
            $record['security_an'] = $answer;
            $record['tel'];
            $record['address'];
            $record['marry'];
            $record['usrinfo'];
            
            $insertsql = $this->db->GetInsertSQL($rs, $record);
            $res = $this->db->Execute($insertsql);
            
            
            //******** login admin **************************
            $this->loginAdminData ($admin , $pwd , $power , $res->Insert_ID( )//取得刚插入的记录集);//
        }
        catch(Exception $e)
        {
            echo $e->getMessage();
            exit;
        }
可是报Bad $rs in GetInsertSQL. Connection or SQL invalid. Try using $connection->debug=true;


Fatal error: Call to a member function Insert_ID() on a non-object in d:\wamp\www\blog\datafile\usrdata.php on line 92
错误

TOP

Insert_ID方法是adodb的,而不是ADORecordSet的

这种分配是与php的数据库函数是一致的
需要通过数据库连接资源link_identifier取得,而不是通过查询资源result取得

在执行插入指令的时候是没有资源返回的,只返回逻辑值
一個偽裝成白癡的天纔!

TOP

发新话题