简体   繁体   English

Zend Db更新不起作用

[英]Zend Db Update Not working

My table structure is: 我的表结构是:

TABLE `licenses` (
`id` int(11) NOT NULL auto_increment,
`code` varchar(30) collate utf8_unicode_ci NOT NULL,
`title` varchar(255) collate utf8_unicode_ci NOT NULL,
`description` text collate utf8_unicode_ci NOT NULL,
`license_type` char(1) collate utf8_unicode_ci NOT NULL default 'b',
PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;

Currently there is data: 当前有数据:

(`id`, `code`, `title`, `description`, `license_type`)
(2, 'asd', 'asdt', 'asdd', 'b')

My database object is fine and working: $db [Class: Zend_Db_Adapter_Pdo_Mysql ] 我的数据库对象运行正常:$ db [Class:Zend_Db_Adapter_Pdo_Mysql]

I am using this to update: 我正在使用它来更新:

$data=array( 'id' => 2 , 'code' => 'asd' ,  'title' => 'asdt' , 'description' => 'asdd' , 'license_type' => 'b');

$db->update('licenses' , $data  , $db->quoteInto(" id = ? " , $data['id']));   

Its returning a rowcount = 0; 它返回的行数= 0; And nothing is being updated in database. 数据库中没有任何更新。

My database is Mysql. 我的数据库是Mysql。 Anyone has any idea, whats happening. 任何人都有任何想法,发生了什么事。

The thing is that, $db->update(....) returns '0' even if sql was executed, but data which was provided as the bind parameter ($data above) is the original data contained in table, I mean when sql is not changing the data. 问题是,即使执行了sql,$ db-> update(....)也会返回“ 0”,但是作为绑定参数提供的数据(上面的$ data)是表中包含的原始数据,我的意思是当sql不更改数据时。 So our code cannot rely on returned row count. 因此,我们的代码不能依赖返回的行数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM