本文整理汇总了PHP中Type::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::find方法的具体用法?PHP Type::find怎么用?PHP Type::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
if (Type::got_property($id) == false) {
$this->type->find($id)->delete();
}
return Redirect::route('admin.types.index');
}
示例2: searchAction
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "ProductTypes", $_POST);
$this->persistent->searchParams = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($this->persistent->searchParams) {
$parameters = $this->persistent->searchParams;
}
$productTypes = Type::find($parameters);
if (count($productTypes) == 0) {
$this->flash->notice("没有找到对应类型");
return $this->forward("producttypes/index");
}
$paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $productTypes, "limit" => 10, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
$this->view->setVar("productTypes", $productTypes);
}
示例3: getDelete
public function getDelete($id)
{
$Type = Type::find($id);
$Type->delete();
Session::flash('message', 'The records are deleted successfully');
return Redirect::to('type');
}
示例4: beforeDelete
function beforeDelete($cascade)
{
// Remove the extended data to be tidy.
// First get the type id
App::Import('Model', 'Type');
$Type = new Type();
$Type->recursive = -1;
$type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
$type_id = $type_record[0];
// Cool, now find all node schemas
App::Import('Model', 'NodeSchema.NodeSchema');
$NodeSchema = new NodeSchema();
$NodeSchema->actsAs = array('Containable');
$schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
// Now loop through and check for records on those tables to remove
if (is_array($schemas) && count($schemas) > 0) {
foreach ($schemas as $schema) {
$table_name = $schema['NodeSchema']['table_name'];
$model = new Model(false, $table_name);
$model->primaryKey = 'node_id';
// set the primary key to the node_id
if ($model->delete($this->model->data['Node']['id'], false)) {
return true;
} else {
// return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
}
}
}
return true;
}
示例5: specific_type
public function specific_type($id)
{
$type = Type::find($id);
$medicines = $type->medicine;
$name = $type->type;
//$pets = Pet::where("type_id", "Compact Living")->get();
return View::make('medicines.index', compact('medicines', 'name', 'type'));
}
示例6: edit
/**
* Display a listing of the resource.
*
* @return Response
*/
public function edit($id)
{
$school = School::find($id);
if (is_null($school)) {
return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Училището не е намерено.'));
} else {
$school_name = Type::find($school->type_id)->name . ' "' . $school->name . '"';
$comments = VisitorComments::where("school_id", "=", $id)->get();
return View::make('admin.school.comments')->with('school_name', $school_name)->with('comments', $comments);
}
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$type = Type::find($id);
if (!is_null($type)) {
if ($type->delete()) {
return Redirect::route('admin.types.index')->withErrors(array('mainSuccess' => 'Видът на учебното заведение е успешно изтрит.'));
} else {
return Redirect::route('admin.types.index')->withErrors(array('mainError' => 'Грешка с базата данни.'));
}
} else {
return Redirect::route('admin.types.index')->withErrors(array('mainError' => 'Вид на училище не е намерен.'));
}
}
示例8: type
public function type()
{
if (!isset($_GET['url'])) {
exit;
}
# TODO
$type = new Type(array("url" => $_GET['url']));
if ($type->no_results) {
exit;
}
# TODO
$can_create = Visitor::current()->group()->can("add_extension");
$this->display("extend/type", array("type" => $type, "users" => $can_create ? User::find() : array(), "types" => $can_create ? Type::find() : array()), $type->name);
}
示例9: editAction
public function editAction($id)
{
$request = $this->request;
if (!$request->isPost()) {
$id = $this->filter->sanitize($id, array("int"));
$Finance = Finance::findFirst('id="' . $id . '"');
if (!$Finance) {
$this->flash->error("这条记录没有找到!");
return $this->forward("products/list");
}
$departments = Department::find();
$this->view->setVar("departments", $departments);
Tag::displayTo("company", $Finance->did);
$typeArr;
$type = Type::find();
foreach ($type as $k => $v) {
$types = Types::find("fid = '" . $v->id . "'");
$typeArr[$v->name] = $types->toArray();
}
$this->view->setVar("typeArr", $typeArr);
$this->view->setVar("id", $Finance->id);
$datas = json_decode($Finance->data, true);
foreach ($typeArr as $key => $val) {
foreach ($val as $k => $v) {
if (isset($datas['cost'][$v['name']]) && $datas['cost'][$v['name']] != '') {
Tag::displayTo("cost[" . $v['name'] . "]", $datas['cost'][$v['name']]);
}
if (isset($datas['remark'][$v['name']]) && $datas['remark'][$v['name']] != '') {
Tag::displayTo("remark[" . $v['name'] . "]", $datas['remark'][$v['name']]);
}
if (isset($datas['limit'][$v['name']]) && $datas['limit'][$v['name']] != '') {
Tag::displayTo("limit[" . $v['name'] . "]", $datas['limit'][$v['name']]);
}
}
}
Tag::displayTo("id", $Finance->id);
$auth = $this->session->get("auth");
if ($auth['did'] != 0) {
Tag::setDefault("company", $auth['did']);
}
$this->view->setVar('did', $auth['did']);
/*
Tag::displayTo("product_types_id", $products->product_types_id);
Tag::displayTo("name", $products->name);
Tag::displayTo("price", $products->price);
Tag::displayTo("active", $products->active);
$this->view->setVar("productTypes", ProductTypes::find());
*/
}
}
示例10: test_find
function test_find()
{
//Arrange
$descript = "Event Keepsakes";
$descript2 = "Antiques";
$test_Type = new Type($descript);
$test_Type->save();
$test_Type2 = new Type($descript2);
$test_Type2->save();
//Act
$result = Type::find($test_Type->getId());
//Assert
$this->assertEquals($test_Type, $result);
}
示例11: postType
public function postType($type_id)
{
$all = Input::all();
$rules = array('name' => 'required|min:2|max:255', 'type' => 'required|min:3|max:255');
$validator = Validator::make($all, $rules);
if ($validator->fails()) {
return Redirect::to('/admin/content/' . $type_id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
}
if (is_numeric($type_id)) {
$post = Type::find($type_id);
} else {
$post = new Type();
}
$post->type = $all['type'];
$post->name = $all['name'];
$post->template = $all['template'];
$post->title = $all['title'];
$post->text = $all['text'];
$post->status = isset($all['status']) ? true : false;
$post->save();
return Redirect::to('/admin/content/' . $type_id)->with('success', 'Изменения сохранены');
}
示例12: postTypeEdit
public function postTypeEdit($TypeId)
{
$rules = array('name' => 'required|min:2|unique:type,name,' . $TypeId, 'code' => 'required|unique:type,code,' . $TypeId);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('branch/type-edit/' . $TypeId)->withErrors($validator)->withInput();
}
$type = Type::find($TypeId);
$type->name = Input::get('name');
$type->code = Input::get('code');
$type->day = Input::get('day');
$type->save();
return Redirect::to('branch/type')->with('success', '客户类型更新成功!');
}
示例13: type
function type($id = FALSE)
{
$this->load->helper('notification');
if ($_POST) {
unset($_POST['send']);
unset($_POST['_wysihtml5_mode']);
$id = $_POST['id'];
unset($_POST['id']);
$ticket = Ticket::find_by_id($id);
$attr = array('type_id' => $_POST['type_id']);
$ticket->update_attributes($attr);
if (!$ticket) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_assign_type_error'));
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_assign_type_success'));
}
redirect('tickets/view/' . $id);
} else {
$this->view_data['types'] = Type::find('all', array('conditions' => array('inactive=?', '0')));
$this->view_data['ticket'] = Ticket::find_by_id($id);
$this->theme_view = 'modal';
$this->view_data['title'] = $this->lang->line('application_type');
$this->view_data['form_action'] = 'tickets/type';
$this->content_view = 'tickets/_type';
}
}
示例14: actionAdd
public function actionAdd()
{
$type = Type::find()->all();
return $this->render('add', ['type' => $type]);
}
示例15: getZkillboard
/**
* Import zKillboard kills for the selected systems and alliances.
*/
public function getZkillboard($systems = '')
{
// If this is the initial call to the function, retrieve the list of systems from the DB.
if ($systems == '') {
$systems_object = Setting::where('key', 'systems')->firstOrFail();
$systems = $systems_object->value;
}
// Convert the comma-seperated string into an array.
$systems_array = explode(',', $systems);
// If there are more systems in the list than we want to pull at once, chop off the first X and call this function again.
while (count($systems_array) > $this->api_system_limit) {
$this->getZkillboard(implode(',', array_splice($systems_array, 0, $this->api_system_limit)));
}
// Retrieve the selected alliances from the database.
$alliances = Setting::where('key', 'alliances')->firstOrFail();
// Build the API URL.
$url = 'https://zkillboard.com/api/xml/losses/no-attackers/' . 'allianceID/' . preg_replace('/\\s+/', '', $alliances->value) . '/' . 'solarSystemID/' . preg_replace('/\\s+/', '', $systems) . '/';
// Send the request.
$response = Request::get($url)->addHeader('Accept-Encoding', 'gzip')->addHeader('User-Agent', 'Eve Traders Handbook')->send();
if (isset($response->body) && strlen($response->body) > 0) {
$body = simplexml_load_string(gzdecode($response->body));
$insert_count = 0;
// Parse the response, inserting the losses into the database.
foreach ($body->result->rowset->row as $row) {
// First check whether this kill has not already been recorded.
$kill = Kill::find($row['killID']);
if (!isset($kill->killID)) {
// Create and save the new kill record.
$kill = new Kill();
$kill->killID = $row['killID'];
$kill->solarSystemID = $row['solarSystemID'];
$kill->characterID = $row->victim['characterID'];
$kill->characterName = $row->victim['characterName'];
$kill->allianceID = $row->victim['allianceID'];
$kill->corporationID = $row->victim['corporationID'];
$kill->shipTypeID = $row->victim['shipTypeID'];
$kill->killTime = $row['killTime'];
$kill->save();
$insert_count++;
// Insert the alliance information into the database unless it already exists.
$alliance = Alliance::find($kill->allianceID);
if (!isset($alliance->id)) {
$alliance = new Alliance();
$alliance->id = $kill->allianceID;
$alliance->allianceName = $row->victim['allianceName'];
$alliance->save();
}
// Insert the corporation information into the database unless it already exists.
$corporation = Corporation::find($kill->corporationID);
if (!isset($corporation->id)) {
$corporation = new Corporation();
$corporation->id = $kill->corporationID;
$corporation->corporationName = $row->victim['corporationName'];
$corporation->save();
}
// Insert the ship type that was lost into the database unless it already exists.
$ship = Ship::find($kill->shipTypeID);
$type = Type::find($kill->shipTypeID);
if (!isset($ship->id)) {
$ship = new Ship();
$ship->id = $kill->shipTypeID;
$ship->shipName = $type->typeName;
$ship->save();
}
// Insert the ship loss into the items database as well.
if (stristr($ship->shipName, 'Capsule') === FALSE) {
$item = new Item();
$item->killID = $row['killID'];
$item->typeID = $kill->shipTypeID;
$item->typeName = $type->typeName;
$item->categoryName = $type->group->category['categoryName'];
$item->metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : '';
$item->allowManufacture = 1;
$item->qty = 1;
$item->save();
}
// Add the category to the list of filters available on the site.
$filter = Filter::find($type->group->category['categoryID']);
if (!isset($filter->categoryID)) {
$filter = new Filter();
$filter->categoryID = $type->group->category['categoryID'];
$filter->categoryName = $type->group->category['categoryName'];
$filter->iconID = $type->group->category['iconID'];
$filter->save();
}
// Loop through the items lost in the kill. Insert each one into the items table.
if (isset($row->rowset->row)) {
foreach ($row->rowset->row as $loss) {
$typeID = (int) $loss['typeID'];
$item = Item::where('typeID', '=', $typeID)->first();
// If this item already exists in the items table, we don't need to re-query all the additional
// information, we can just copy it from an existing row.
if (isset($item)) {
// This type has already been seen. Duplicate the record and save the new instance.
$clone = new Item();
$clone = $item->replicate();
// Update the right killID and quantity, and unset the primary key and date columns.
//.........这里部分代码省略.........