function recommendations_featured($job, $step) { $fw = \Base::instance(); $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}"; $old = "{$fw['installerCFG.db3.dbname']}`.`{$fw['installerCFG.db3.prefix']}fanfiction_"; $i = 0; $newdata = new \DB\SQL\Mapper($fw->db5, $fw['installerCFG.db5.prefix'] . "featured"); $dataIn = $fw->db3->exec("SELECT Rec.recid as id, Rec.featured as status, 'RC' as type FROM `{$old}recommendations`Rec WHERE Rec.featured > 0;"); foreach ($dataIn as $data) { $i++; $newdata->copyfrom($data); $newdata->save(); $newdata->reset(); } $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 2, `items` = :items WHERE `id` = :id ", [':items' => $i, ':id' => $step['id']]); }
function textblocks_copy($job, $step) { // Copy the existing blocks $fw = \Base::instance(); $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}"; $old = "{$fw['installerCFG.db3.dbname']}`.`{$fw['installerCFG.db3.prefix']}fanfiction_"; $i = 0; $newdata = new \DB\SQL\Mapper($fw->db5, $fw['installerCFG.db5.prefix'] . "textblocks"); $dataIn = $fw->db3->exec("SELECT message_id as id, message_name as label, message_title as title, message_text as content, 1 as as_page FROM `{$old}messages`;"); foreach ($dataIn as $data) { $i++; $newdata->copyfrom($data); $newdata->save(); $newdata->reset(); } $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 2, `items` = :items WHERE `id` = :id ", [':items' => $i, ':id' => $step['id']]); }
function users_fields($job, $step) { /* 1 = URL 2 = Options 3 = yes/no 4 = URL with ID 5 = code -> now tpl field 6 = text */ $fw = \Base::instance(); $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}"; $old = "{$fw['installerCFG.db3.dbname']}`.`{$fw['installerCFG.db3.prefix']}fanfiction_"; $limit = 50; $i = 0; $newdata = new \DB\SQL\Mapper($fw->db5, $fw['installerCFG.db5.prefix'] . "user_fields"); $dataIn = $fw->db3->exec("SELECT `field_id`, `field_type`, `field_name`, `field_title`, `field_options`, `field_code_out`, `field_on`\r\n\t\t\t\t\t\t\tFROM `{$old}authorfields`\r\n\t\t\t\t\t\t\tORDER BY `field_id` ASC;"); foreach ($dataIn as $data) { $i++; if ($data['field_type'] == 2) { $data['field_options'] = json_encode(explode("|#|", $data['field_options'])); } if ($data['field_type'] == 5) { // Code fields are now tpl fields $data['field_options'] = $data['field_code_out']; // Disable, so it won't show weird stuff before being modified $data['field_on'] = 0; } $newdata->copyfrom($data); $newdata->save(); $newdata->reset(); } // Add avatar field (formerly image from author info) //$fw->db5->exec("INSERT INTO `{$new}user_fields` ( field_type, field_name, field_title ) VALUES ( 1, 'avatar', 'Avatar' );"); $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 2, `items` = :items WHERE `id` = :id ", [':items' => $i, ':id' => $step['id']]); }
function various_poll($job, $step) { $fw = \Base::instance(); $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}"; $old = "{$fw['installerCFG.db3.dbname']}`.`{$fw['installerCFG.db3.prefix']}fanfiction_"; $limit = 20; $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert'); $tracking->load(['id = ?', $step['id']]); $newdata = new \DB\SQL\Mapper($fw->db5, $fw['installerCFG.db5.prefix'] . "poll"); if ($step['success'] == 0) { try { $total = $fw->db3->exec("SELECT COUNT(*) as found FROM `{$old}poll`;")[0]['found']; $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]); } catch (PDOException $e) { // There's no source table, so we just finish with 0 entries $tracking->items = -1; $tracking->success = 2; $tracking->save(); return TRUE; // escape plan } } $dataIn = $fw->db3->exec("SELECT `poll_id`, `poll_question` as question, `poll_opts` as options, `poll_start` as start_date, `poll_end` as end_date, `poll_results` as results\r\n\t\t\t\t\t\t\t\tFROM `{$old}poll` \r\n\t\t\t\t\t\t\t\tORDER BY `poll_id` ASC LIMIT {$step['items']},{$limit};"); if (0 < ($count = sizeof($dataIn))) { foreach ($dataIn as $data) { $data['results'] = $data['results'] == NULL ? NULL : json_encode(explode("#", $data['results'])); $data['options'] = json_encode(explode("|#|", $data['options'])); $newdata->copyfrom($data); $newdata->save(); $newdata->reset(); $tracking->items = $tracking->items + 1; $tracking->save(); } } if ($count == 0 or $count <= $limit) { // There was either nothing to be done, or there are no elements left for the next run $tracking->success = 2; $tracking->save(); } }
public function saveShout($id, array $data) { $shout = new \DB\SQL\Mapper($this->db, $this->prefix . 'shoutbox'); $shout->load(array('id=?', $id)); $shout->copyfrom(["message" => $data['message']]); $i = $shout->changed("message"); $shout->save(); return $i; }