本文整理汇总了PHP中Route::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::save方法的具体用法?PHP Route::save怎么用?PHP Route::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create the application document registry
*
* @param array $aData
* @return string
*
*/
public function create($aData)
{
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
try {
$sRouteUID = G::generateUniqueID();
$aData['ROU_UID'] = $sRouteUID;
$oRoute = new Route();
// validating default values
$aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE');
$aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE');
$aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL'] : '', array('TRUE', 'FALSE'), 'TRUE');
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oRoute->validate()) {
$oConnection->begin();
$iResult = $oRoute->save();
$oConnection->commit();
return $sRouteUID;
} else {
$sMessage = '';
$aValidationFailures = $oRoute->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw new Exception('The registry cannot be created!<br />' . $sMessage);
}
} catch (Exception $oError) {
$oConnection->rollback();
throw $oError;
}
}
示例2: save
/**
* Save this walk to the database
* Also saves any route attached to the walk
*/
public function save()
{
$db = JFactory::getDbo();
// Commit everything as one transaction
$db->transactionStart();
$query = $db->getQuery(true);
// First, do the basic fields
foreach ($this->dbmappings as $var => $dbField) {
$query->set($dbField . " = '" . $db->escape($this->{$var}) . "'");
}
$query->set("suggestedby = " . $this->suggestedBy->id);
// Update or insert?
if (!isset($this->id)) {
$query->insert("walks");
} else {
$query->where("ID = " . (int) $this->id);
$query->update("walks");
}
$db->setQuery($query);
$db->query();
if (!isset($this->id)) {
// Get the ID from the database
$this->id = $db->insertid();
}
// TODO: Handle failure
// Commit the transaction - the route is not a critical part of the walk
$db->transactionCommit();
// Now save the route
if (isset($this->route)) {
$this->route->save();
}
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$route = new Route();
$route->name = $request['name'];
$route->distance = $request['distance'];
$route->duration = $request['duration'];
$route->price = $request['price'];
$route->save();
}
示例4: insert_routes
public function insert_routes(Request $request)
{
$route = new Route();
$route->route_name = $request->input('name');
$route->start = $request->input('start');
$route->end = $request->input('end');
$route->rep_id = $request->input('rep');
$route->remarks = $request->input('remarks');
$route->save();
}
示例5: seeder
public function seeder()
{
//adding new route
$route = new Route();
$route->name = '/login';
$route->save();
//adding a method to route
$method = $route->methods()->create(['tags' => 'customer', 'method' => 'POST', 'description' => 'Post operation on customer route']);
//adding parameters to method
$method->parameters()->create(['name' => 'mobile', 'in' => 'formData', 'description' => 'mobile number of customer', 'required' => true, 'type' => 'string']);
$method->parameters()->create(['name' => 'password', 'in' => 'formData', 'description' => 'password of customer', 'required' => true, 'type' => 'string']);
return true;
}
示例6: addapi
public function addapi()
{
if (isset($_POST) == true && empty($_POST) == false) {
$api = $_POST['api'];
$methodName = $_POST['method'];
$tags = $_POST['tags'] ? $_POST['tags'] : 'default';
$description = $_POST['description'] ? $_POST['description'] : ' ';
$BX_NAME = $_POST['BX_NAME'];
$BX_TYPE = $_POST['BX_TYPE'];
$BX_CHK = $_POST['BX_CHK'];
$BX_DESCRIPTION = $_POST['BX_DESCRIPTION'];
$BX_IN = $_POST['BX_IN'];
$param_count = count($BX_NAME);
//check if route already exists
$route = Route::where('name', '=', $api)->first();
if (!$route) {
//adding new route
$route = new Route();
$route->name = $api;
$route->save();
}
$method = $route->methods()->where('method', '=', $methodName)->firstOrCreate(['tags' => $tags, 'method' => $methodName, 'description' => $description]);
//parameters
//if blank field submitted in parameter don't add it
for ($i = 0; $i < $param_count; $i++) {
if ($BX_NAME[$i] != '') {
$BX_CHK[$i] = 'on' ? true : false;
$BX_DESCRIPTION[$i] = $BX_DESCRIPTION[$i] ? $BX_DESCRIPTION[$i] : ' ';
$method->parameters()->create(['name' => $BX_NAME[$i], 'in' => $BX_IN[$i], 'description' => $BX_DESCRIPTION[$i], 'required' => $BX_CHK[$i], 'type' => $BX_TYPE[$i]]);
}
//END if
}
//for
header('location: ' . URL . '/show');
} else {
header('location: ' . URL . '/show');
}
//if-else post
}
示例7: actionAddInfo
public function actionAddInfo()
{
$source = '';
$thumb = '';
if (isset($_POST['source'])) {
$source = $_POST['source'];
}
if (isset($_POST['thumb'])) {
$thumb = $_POST['thumb'];
}
$route = new Route();
$route->name = $_POST['title'];
$route->area = $_POST['area'];
$route->port = $_POST['port'];
$route->style = $_POST['style'];
$route->company = $_POST['company'];
$route->source = $source;
$route->thumb = $thumb;
$route->description = $_POST['description'];
$route->start_time = $_POST['date'];
$route->continent = $_POST['continent'];
$route->save();
echo 1;
}
示例8: setPath
/**
* Sets the Route's path field
* @param int $path [optional]
* @return bool
*/
public function setPath($path, $load = true)
{
# Prepare
$save = false;
# Prepare
$path = trim($path, '/');
if (empty($path)) {
return false;
}
# Update
if ($this->Route_id) {
$Route = $this->Route;
} else {
$Route = new Route();
$Route->type = 'content';
$Route->data = array('id' => $this->id);
$this->Route = $Route;
$save = true;
}
# Apply
if ($Route->path != $path) {
$Route->path = $path;
$Route->save();
# Update Children
$Children = $this->Children;
foreach ($Children as $Child) {
$Child->setPath($path . '/' . $Child->code);
}
}
# Done
return $save;
}