经过大量研究,我可以连接 ADOBD mssql y free tds,但现在我遇到了另一个问题,我尝试使用 Active record ,插入指令但我做不到,ado 没有给我发送任何错误.. . 这是我的脚本:
include('adodb/adodb.inc.php');
include('adodb/adodb-active-record.inc.php');
$db = ADONewConnection('mssql'); # eg 'mysql' or 'postgres'
$db->Connect('*********', "*********", '**********', "**********");
ADOdb_Active_Record::SetDatabaseAdapter($db);
ADODB_Active_Record::$_changeNames = FALSE;
$db->debug = true;
#the following example use a table that was created with this statement
$rs = $db->Execute("select top 3 * from banks order by 1 desc");
print "<pre>";
print_r($rs->GetRows());
print "</pre>";
#create an empty class to work with our new table
class banks extends ADOdb_Active_Record {} $banks2 = new banks();
$banks2->desc_bank = 'Banco '.date("H:i:s d/m/Y");
$banks2->save(); // this save() will fail on INSERT as favorite_color is a must fill...
echo "<br/> Guarde: el id = '$banks2->id_bank - $banks2->desc_bank ".date("H:i:s d/m/Y")."'";
$ok = $banks2->Save();
if (!$ok) $err = $banks2->ErrorMsg();
echo "<br> Error= $err";
unset($banks);
// $rs = $db->Execute("insert into banks values('".'Banco '.date("H:i:s d/m/Y")."')");
$rs = $db->Execute("select top 3 * from banks order by 1 desc");
print "<pre>";
print_r($rs->GetRows());
print "</pre>";
echo "<br/> Acabe: ".date("H:i:s d/m/Y");
如果我取消注释它所做的正常插入,但这不是活动记录
This is the response:
> (mssql): select top 3 * from banks order by 1 desc
Array
(
[0] => Array
(
[0] => 26
[1] => Banco 10:54:29 26/04/2012
)
[1] => Array
(
[0] => 25
[1] => Banco 10:54:18 26/04/2012
)
[2] => Array
(
[0] => 23
[1] => BANSEFI 2
)
)
(mssql): select c.name,t.name,c.length,c.isnullable, c.status, (case when c.xusertype=61 then 0 else c.xprec end), (case when c.xusertype=61 then 0 else c.xscale end) from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='banks' (mssql): select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, information_schema.table_constraints tc where tc.constraint_name = k.constraint_name and tc.constraint_type = 'PRIMARY KEY' and k.table_name = 'banks' and k.table_catalog like 'tss_dev%' order by ordinal_position (mssql): INSERT INTO banks(id_bank,desc_bank) VALUES (?,?) [ (0=>null) (1=>'Banco 11:05:42 26/04/2012') ] sp_executesql N'INSERT INTO banks(id_bank,desc_bank) VALUES (@P0,@P1); select SCOPE_IDENTITY()',N'@P0 CHAR, @P1 NVARCHAR(25)',@P0=NULL, @P1=N'Banco 11:05:42 26/04/2012'
(mssql): select SCOPE_IDENTITY() (mssql): select max(id_bank) from banks
Guarde: el id = '26 - Banco 11:05:42 26/04/2012 11:05:42 26/04/2012'
Error= (mssql): select top 3 * from banks order by 1 desc
Array
(
[0] => Array
(
[0] => 26
[1] => Banco 10:54:29 26/04/2012
)
[1] => Array
(
[0] => 25
[1] => Banco 10:54:18 26/04/2012
)
[2] => Array
(
[0] => 23
[1] => BANSEFI 2
)
)
Acabe: 11:05:42 26/04/2012
这是表银行
USE [tss_dev]
GO
/****** Object: Table [dbo].[banks] Script Date: 26/04/2012 11:17:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[banks](
[id_bank] [smallint] IDENTITY(22,1) NOT NULL,
[desc_bank] [char](30) NOT NULL,
CONSTRAINT [PK_banks_id_bank] PRIMARY KEY CLUSTERED
(
[id_bank] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_SSMA_SOURCE', @value=N'tss_sales_demo.banks' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'banks'
GO
谢谢你的帮助伙计们..!!!