Salvatore Lapi Wed Sep 10 14:09:46 -0400 2014

Subject: Transaction

I would like to create a transaction on multiple tables, in serizable mode. Can you help? When I put everything I used adodb between startTrans () and completeTrans () as I do in php active record? can you give me an example?


Bill Zhao Mon Oct 20 05:09:09 -0400 2014
 1     public static function create($title, $parentId = 1)
 2     {
 3         $definition = new static;
 4 
 5         static::transaction(
 6             function() use ($definition, $title, $parentId) {
 7                 $definition->title = $title;
 8                 if ($definition->is_invalid()) {
 9                     throw new static::$exception($definition->errors->on('title'));
10                 }
11                 $definition->save();
12                 $definition->create_first_version()->create_system_nodes();
13                 $definition->create_category(
14                     array(
15                         'name' => $definition->title,
16                         'parent_id' => $parentId
17                     )
18                 );
19             }
20         );
21 
22         return $definition;
23     }

(1-1/1)