本文整理汇总了PHP中Definition::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::save方法的具体用法?PHP Definition::save怎么用?PHP Definition::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Definition
的用法示例。
在下文中一共展示了Definition::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: seedShp
/**
* Seed the SHP definitions
*/
private function seedShp()
{
$shp_data = array('rivers' => array('file' => 'gis.osm_boundaries_v06', 'collection' => 'dresden', 'name' => 'rivers', 'description' => 'Shape file about rivers in Dresden.', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'lastchange', 'index' => 1, 'column_name_alias' => 'lastchange', 'is_pk' => 0), array('column_name' => 'code', 'index' => 2, 'column_name_alias' => 'code', 'is_pk' => 0), array('column_name' => 'fclass', 'index' => 3, 'column_name_alias' => 'fclass', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'parts', 'index' => 5, 'column_name_alias' => 'parts', 'is_pk' => 0)), 'geo' => array(array('path' => 'parts', 'property' => 'polyline'))), 'places' => array('file' => 'places', 'name' => 'places', 'collection' => 'france', 'description' => 'Interesting places from "Ile-de-France".', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'name', 'index' => 1, 'column_name_alias' => 'name', 'is_pk' => 0), array('column_name' => 'type', 'index' => 2, 'column_name_alias' => 'type', 'is_pk' => 0), array('column_name' => 'population', 'index' => 3, 'column_name_alias' => 'population', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'x', 'index' => 5, 'column_name_alias' => 'x', 'is_pk' => 0), array('column_name' => 'y', 'index' => 6, 'column_name_alias' => 'y', 'is_pk' => 0)), 'geo' => array(array('path' => 'x', 'property' => 'latitude'), array('path' => 'y', 'property' => 'longitude'))));
$added = false;
foreach ($shp_data as $directory => $info) {
// Don't create doubles
$definition = Definition::where('collection_uri', '=', $info['collection'])->where('resource_name', '=', $info['name'])->first();
if (empty($definition)) {
// Create a new ShpDefinition
$shp_def = new ShpDefinition();
$shp_def->uri = app_path() . '/storage/data/shp/' . $directory . '/' . $info['file'] . '.shp';
$shp_def->description = $info['description'];
$shp_def->epsg = 4326;
$shp_def->save();
// Add the tabular columns
foreach ($info['columns'] as $column) {
$tab_column = new TabularColumns();
$tab_column->column_name = $column['column_name'];
$tab_column->index = $column['index'];
$tab_column->column_name_alias = $column['column_name_alias'];
$tab_column->is_pk = $column['is_pk'];
$tab_column->tabular_id = $shp_def->id;
$tab_column->tabular_type = 'ShpDefinition';
$tab_column->save();
}
// Add the geo properties
foreach ($info['geo'] as $geo) {
$geo_prop = new GeoProperty();
$geo_prop->source_type = 'ShpDefinition';
$geo_prop->source_id = $shp_def->id;
$geo_prop->property = $geo['property'];
$geo_prop->path = $geo['path'];
$geo_prop->save();
}
// Add the ShpDefinition to the Definition
$definition = new Definition();
$definition->collection_uri = $info['collection'];
$definition->resource_name = $info['name'];
$definition->source_id = $shp_def->id;
$definition->source_type = 'ShpDefinition';
$definition->draft = false;
$definition->save();
$this->command->info("Published a SHP file.");
$added = true;
}
}
if (!$added) {
$this->command->info("No SHP files have been published, all of the uri's that the SHP seeder wanted to use are already taken.");
}
}
示例2: cleanupReferences
$count = 0;
$dropped = 0;
$kept = 0;
while (($dbRow = mysql_fetch_assoc($dbResult)) != null) {
$d = new Definition();
$d->populateFromDbRow($dbRow);
$count++;
if ($count % 10000 == 0) {
print "{$count} definitions examined, {$dropped} dropped, {$kept} kept\n";
}
$newRep = cleanupReferences($d->internalRep);
if ($newRep != $d->internalRep) {
//print "{$d->internalRep}\n{$newRep}\n";
$d->internalRep = $newRep;
$d->htmlRep = text_htmlize($d->internalRep);
$d->save();
}
}
print "{$count} definitions examined, {$dropped} dropped, {$kept} kept\n";
function cleanupReferences($s)
{
global $dropped;
global $kept;
$result = '';
$text = '';
$ref = '';
$mode = 0;
// 0 = not between bars; 1 = text; 2 = reference
for ($i = 0; $i < strlen($s); $i++) {
$char = $s[$i];
if ($char == '|') {