1 [[!meta title="Dendis Martin"]]
3 **Project name and homepage:** [Nette](http://nette.org)
8 I'd like to help fix some bugs in database layout I've discovered
10 (a) If I have in database column with type time/timeint, database layout will return it's values as instance of class DateInterval. But when I want to insert or update this column, database layout can't process DateInterval & crashes.
13 // This works just fine
14 $actRow = $this->connection->table('test')->insert(array('time' => '1:30:00'));
16 // But this will crash, because database layout can't deal with class DateInterval on insert or update
17 $actRow = $this->connection->table('test')->insert(array('time' => new \DateInterval('PT1H30M')));
20 $actRow = $this->connection->table('test')->insert(array('time' => '1:30:00'));
21 echo $actRow['time'] instanceof \DateInterval ? 'Yes' : 'No'; // Will print Yes
23 (b) If I'm working with ActivRow and I want to update column which is defined as primary key the app crashes. It's because after each update of ActiveRow database layout fetches (refreshes) row from database, but with old values of primary keys. Seethe example:
25 // In database I have in table test defined column id as primary key
26 $actRow = $this->connection->table('test')->insert(array('username' => 'marek'));
28 // This operation will fail, the data in the database has been modified
29 // But after update, database layout will try to refresh ActiveRow from database
30 // and use old primary key 'marek' instead of new one 'ondra' so no record is found and exception is thrown
31 $actRow->update(array('username' => 'ondra'));
33 and maybe some others...
36 Links documenting the results of my work
39 Ok, so for now I've created some issues on GitHub & waiting for reply from members of the project
41 1. [Problem with \DateInterval object on insert/update](https://github.com/nette/database/issues/56) (update: David Grudl solved my problem before I could do it by myself, even though I asked about the possibility of my own implementation.)
42 2. [ActiveRow problem with update of primary key](https://github.com/nette/database/issues/57)
47 [[Presentation_of_the_aim_of_my_work.pdf]]
53 Here, I'll fill in the HTML code of the [Ohloh widgetu][w] showing my KudoRank.
57 [w]:https://www.ohloh.net/accounts/dendimar/widgets