本文整理汇总了PHP中text::save方法的典型用法代码示例。如果您正苦于以下问题:PHP text::save方法的具体用法?PHP text::save怎么用?PHP text::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text
的用法示例。
在下文中一共展示了text::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
function upgrade()
{
global $db;
// copy each locationref entry to the sectionref
$srs = $db->selectObjects('sectionref', "module = 'headlineController'");
foreach ($srs as $sr) {
$sr->module = 'textController';
$db->updateObject($sr, 'sectionref');
}
$lrs = $db->selectObjects('locationref', "module = 'headlineController'");
foreach ($lrs as $lr) {
$lr->module = 'textController';
$db->updateObject($lr, 'locationref');
}
$gps = $db->selectObjects('grouppermission', "module = 'headlineController'");
foreach ($gps as $gp) {
$gp->module = 'textController';
$db->updateObject($gp, 'grouppermission');
}
$ups = $db->selectObjects('userpermission', "module = 'headlineController'");
foreach ($ups as $up) {
$up->module = 'textController';
$db->updateObject($up, 'userpermission');
}
// convert each headline module to a text module
$modules_converted = 0;
$cns = $db->selectObjects('container', "internal LIKE '%headlineController%'");
foreach ($cns as $cn) {
$cloc = expUnserialize($cn->internal);
$cloc->mod = 'textController';
$cn->internal = serialize($cloc);
$cn->view = 'showall';
$cn->action = 'showall';
$db->updateObject($cn, 'container');
$modules_converted += 1;
}
// create a text item for each headline item
$headlines_converted = 0;
$headlines = $db->selectObjects('headline', "1");
foreach ($headlines as $hl) {
$text = new text();
$loc = expUnserialize($hl->location_data);
$loc->mod = "text";
$text->location_data = serialize($loc);
$text->title = $hl->title;
$text->poster = $hl->poster;
$text->save();
$text->created_at = $hl->created_at;
$text->edited_at = $hl->edited_at;
$text->update();
$headlines_converted += 1;
}
// FIXME - remove when final
return "TEST - We're NOT removing the locationref table nor the files yet...<br>" . $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>";
// delete headline table
$db->dropTable('locationref');
// check if the headline controller files are there and remove them
$files = array(BASE . "framework/modules/definitions/headline.php", BASE . "framework/modules/models/headline.php", BASE . "framework/modules/headline/");
// delete the files.
$removed = 0;
$errors = 0;
foreach ($files as $file) {
if (expUtil::isReallyWritable($file)) {
unlink($file);
$removed += 1;
} else {
$errors += 1;
}
}
return $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>" . $removed . " files were deleted.<br>" . $errors . " files could not be removed.";
}
示例2: convert
/**
* main routine to convert old school module data into new controller format
* @global db the exponent database object
* @param $iloc
* @param $module
* @param int $hc
* @return
*/
private function convert($iloc, $module, $hc = 0)
{
if (!array_key_exists($iloc->mod, $this->params['migrate'])) {
return $module;
}
global $db;
$old_db = $this->connect();
$linked = false;
$loc = null;
switch ($iloc->mod) {
case 'textmodule':
@($module->view = 'showall');
//check to see if it's already pulled in (circumvent !is_original)
$ploc = $iloc;
$ploc->mod = "text";
if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
$iloc->mod = 'textmodule';
$linked = true;
break;
}
$iloc->mod = 'textmodule';
$textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
if ($textitems) {
foreach ($textitems as $ti) {
$text = new text();
$loc = expUnserialize($ti->location_data);
$loc->mod = "text";
$text->location_data = serialize($loc);
$text->body = $ti->text;
$text->save();
@$this->msg['migrated'][$iloc->mod]['count']++;
@($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
}
}
break;
case 'rotatormodule':
$module->action = 'showRandom';
$module->view = 'showRandom';
//check to see if it's already pulled in (circumvent !is_original)
$ploc = $iloc;
$ploc->mod = "text";
if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
$iloc->mod = 'rotatormodule';
$linked = true;
break;
}
$iloc->mod = 'rotatormodule';
$textitems = $old_db->selectObjects('rotator_item', "location_data='" . serialize($iloc) . "'");
if ($textitems) {
foreach ($textitems as $ti) {
$text = new text();
$loc = expUnserialize($ti->location_data);
$loc->mod = "text";
$text->location_data = serialize($loc);
$text->body = $ti->text;
$text->save();
@$this->msg['migrated'][$iloc->mod]['count']++;
@($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
}
}
break;
case 'snippetmodule':
$module->view = 'showall';
//check to see if it's already pulled in (circumvent !is_original)
$ploc = $iloc;
$ploc->mod = "snippet";
if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
$iloc->mod = 'snippetmodule';
$linked = true;
break;
}
$iloc->mod = 'snippetmodule';
$textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
if ($textitems) {
foreach ($textitems as $ti) {
$text = new snippet();
$loc = expUnserialize($ti->location_data);
$loc->mod = "snippet";
$text->location_data = serialize($loc);
$text->body = $ti->text;
// if the item exists in the current db, we won't save it
$te = $text->find('first', "location_data='" . $text->location_data . "'");
if (empty($te)) {
$text->save();
@$this->msg['migrated'][$iloc->mod]['count']++;
@($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
}
}
}
break;
case 'linklistmodule':
switch ($module->view) {
//.........这里部分代码省略.........