views:

176

answers:

1

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 ]

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; And nothing is being updated in database.

My database is Mysql. Anyone has any idea, whats happening.

+1  A: 

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. So our code cannot rely on returned row count.

Krishna Kant Sharma
The function simply returns the number of affected rows because the row is not modified. Unless your application receives an error or exception, and you've been diligent, you must proceed assuming success
David Caunt