table = WBClass::create('WBDatasource_Table'); $this->fPrimary = $this->table->getIdentifier('vfsfile'); $this->uPrimary = $this->table->getIdentifier('user'); } public function convert() { $options = array( 'flush' => true, 'callback' => $this, 'column' => array( 'views' ) ); $this->table->get('vfsfile', null, null, $clause, $options); } public function onDatasourceGet( $src, $key, &$data ) { $proto = array( $this->fPrimary => $key, $this->uPrimary => 0 ); echo 'save ' . $key . ' views: ' . $data['views'] . "
\n"; $save = array(); for ($i = 0; $i < $data['views']; ++$i) { $save[] = $proto; if($i % 20 == 19) { $this->table->save('vfsfileview', '__new', $save); $save = array(); } } if (!empty($save)) { $this->table->save('vfsfileview', '__new', $save); } } } $v2t = new Views2Table(); $v2t->convert(); ?>