本文整理汇总了PHP中Search::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::save方法的具体用法?PHP Search::save怎么用?PHP Search::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($key_id)
{
$db = new PHPWS_DB('ps_text');
$result = $db->saveObject($this);
if (PHPWS_Error::isError($result)) {
return $result;
}
$search = new Search($key_id);
$search->addKeywords($this->content);
return $search->save();
}
示例2: Search
function save_ticket()
{
$data['parameters'] = $_POST;
$this->load->model('search');
$booking = new Search();
$first_name = $this->input->post('first_name');
$last_name = $this->input->post('last_name');
$identification_nr = $this->input->post('identification_number');
$tickets = $this->input->post('tickets');
if ($this->input->post('tour_back_id') != null) {
$returning = 2;
} else {
$returning = 1;
}
for ($i = 0; $i < $tickets; $i++) {
$booking->client_firstname = $first_name[$i];
$booking->client_lastname = $last_name[$i];
$booking->identification_nr = $identification_nr[$i];
$booking->tour_id = $this->input->post('tour_id');
$booking->tour_back_id = $this->input->post('tour_back_id');
$booking->returning = $returning;
$booking->created_by = $this->session->userdata['user_id'];
$booking->save();
}
$data['title'] = 'Ticket booked successfully';
$data['main_content'] = 'backend/bookings/booking_success';
$this->load->view('includes/template', $data);
}
示例3: switch
}
switch ($_REQUEST['operator']) {
case 'or':
$operator = 'OR';
break;
default:
$operator = 'AND';
break;
}
// end switch on operator
$playlist_name = (string) scrub_in($_REQUEST['playlist_name']);
$playlist = new Search(null, 'song');
$playlist->parse_rules($data);
$playlist->logic_operator = $operator;
$playlist->name = $playlist_name;
$playlist->save();
break;
case 'delete_playlist':
// If we made it here, we didn't have sufficient rights.
UI::access_denied();
break;
case 'show_playlist':
$playlist = new Search($_REQUEST['playlist_id'], 'song');
$playlist->format();
$object_ids = $playlist->get_items();
require_once AmpConfig::get('prefix') . UI::find_template('show_search.inc.php');
break;
case 'update_playlist':
$playlist = new Search($_REQUEST['playlist_id'], 'song');
if ($playlist->has_access()) {
$playlist->parse_rules(Search::clean_request($_REQUEST));
示例4: save
public function save()
{
PHPWS_Core::initModClass('search', 'Search.php');
if (!$this->id) {
$new = true;
$this->create_date = time();
} else {
$new = false;
}
$this->last_updated = time();
// If this page has a parent and the order is not set
// then increment
if (!$this->page_order && $this->parent_page) {
$page_order = $this->getLastPage();
if (!PHPWS_Error::logIfError($page_order)) {
$this->page_order = $page_order + 1;
} else {
$this->page_order = 1;
}
}
$db = new PHPWS_DB('ps_page');
if (PHPWS_Error::logIfError($db->saveObject($this))) {
return false;
}
$this->saveKey();
if ($new && Current_User::isRestricted('pagesmith')) {
Current_User::giveItemPermission($this->_key);
}
$search = new Search($this->key_id);
$search->resetKeywords();
$search->addKeywords($this->title);
PHPWS_Error::logIfError($search->save());
foreach ($this->_sections as $section) {
$section->pid = $this->id;
PHPWS_Error::logIfError($section->save($this->key_id));
}
PHPWS_Cache::remove($this->cacheKey());
}
示例5: pagesmithSearchIndex
/**
* Versions prior to 1.1.0 didn't have search. This function
* plugs in values for all current text sections.
*/
function pagesmithSearchIndex()
{
PHPWS_Core::initModClass('search', 'Search.php');
$db = new PHPWS_DB('ps_text');
$db->addColumn('id');
$db->addColumn('content');
$db->addColumn('ps_page.key_id');
$db->addColumn('ps_page.title');
$db->addWhere('ps_text.pid', 'ps_page.id');
$db->addOrder('pid');
$db->addOrder('secname');
$result = $db->select();
if (!empty($result)) {
if (PHPWS_Error::logIfError($result)) {
return false;
}
foreach ($result as $pg) {
$search = new Search($pg['key_id']);
$search->addKeywords($pg['content']);
$search->addKeywords($pg['title']);
PHPWS_Error::logIfError($search->save());
}
}
return true;
}
示例6: save
function save($save_key = TRUE)
{
$db = new PHPWS_DB('wiki_pages');
$result = $db->saveObject($this);
if (PEAR::isError($result)) {
return $result;
}
if ($save_key) {
$result = $this->saveKey();
if (PEAR::isError($result)) {
return $result;
}
$search = new Search($this->key_id);
$search->resetKeywords();
$search->addKeywords($this->title);
$search->addKeywords($this->pagetext);
$search->save();
}
}
示例7: addKeyword
public static function addKeyword($keyword, $key_id)
{
$search = new Search((int) $key_id);
if ($search->_error) {
PHPWS_Error::log($search->_error);
return;
}
$search->addKeywords($keyword, FALSE);
return $search->save();
}
示例8: function
});
$app->get("/types", function () use($app) {
return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->get("/searches", function () use($app) {
return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/collections", function () use($app) {
$collection = new Collection($_POST['thing']);
$collection->save();
return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll()));
});
$app->post("/types", function () use($app) {
$type = new Type($_POST['descript']);
$type->save();
return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->post("/searches", function () use($app) {
$search = new Search($_POST['find']);
$search->save();
return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/delete_collections", function () use($app) {
Collection::deleteAll();
return $app['twig']->render('delete_collections.html.twig');
});
$app->post("/delete_types", function () use($app) {
Type::deleteAll();
return $app['twig']->render('delete_types.html.twig');
});
return $app;
示例9: executeAddSearchTemplate
public function executeAddSearchTemplate()
{
$this->setLayout(false);
$root = Rootfolder::getRootfolderByModule('search');
$brands = Document::getChildrenOf($root->getId(), 'Brand');
foreach ($brands as $b) {
$brandsArr[$b->getId()] = $b->getLabel();
}
$this->brands = $brandsArr;
$success = false;
if ($objId = $this->getRequestParameter('obj_id')) {
$search = Document::getDocumentInstance($objId);
//var_dump($search);
} else {
$search = new Search();
}
if ($this->getRequestParameter('submit') > '') {
// check input data
$request = $this->getRequest();
$params = $request->getParameterHolder()->getAll();
//var_dump($params);
$brandId = $params['brand'];
$brand = Document::getDocumentInstance($brandId);
//var_dump($brand);
$fields = array('label', 'application_number', 'register_number', 'registration_date', 'application_date', 'expires_on', 'vienna_classes', 'nice_classes', 'rights_owner', 'rights_representative', 'office_of_origin', 'designated_contracting_party');
/*
$search->setLabel($params['label']);
$search->setRightsOwner($params['rights_owner']);
$search->setApplicationNumber($params['application_number']);
$search->setRegisterNumber($params['register_number']);
$search->setRegistrationDate ($params['registration_date']);
$search->setApplicationDate($params['application_date']);
$search->setStatus($params['status']);
$search->setExpiresOn($params['expires_on']);
$search->setViennaClasses($params['vienna_classes']);
$search->setNiceClasses($params['nice_classes']);
//$search->setrightsOwnerAddress($params['rights_owner_address']);
$search->setRightsRepresentative($params['rights_representative']);
//$search->setRightsRepresentativeAddress($params['rights_representative_address']);
$search->setOfficeOfOrigin($params['office_of_origin']);
$search->setDesignatedContractingParty($params['designated_contracting_party']);
*/
$notEmpty = 0;
foreach ($fields as $fl) {
$setter = 'set' . UtilsHelper::convertFieldName($fl);
if (isset($params[$fl])) {
$v = trim($params[$fl]);
if ($v) {
$notEmpty++;
}
$search->{$setter}($v);
} else {
$search->{$setter}(null);
}
}
if ($notEmpty > 0) {
$search->save(null, $brand);
$success = true;
} else {
UtilsHelper::setFlashMsg('Моля, въведете критерии за търсене!', UtilsHelper::MSG_ERROR);
}
//var_dump($search);
}
$this->success = $success;
$this->obj = $search;
}
示例10: make_search_index
/**
* Cette fonction permet la construction des index de recherche
*
* @param array $data Tableau contenant les données à indexer
* @param integer $id Identifiant de l'élément à indexer
* @param varchar $action Type d'action (INSERT ou UPDATE)
* @access public
* @author koéZionCMS
* @version 0.1 - 26/08/2012 by FI
*/
public function make_search_index($datasToSave, $id, $action)
{
//pr($datasToSave);
/**
* La variable $searches_params peut être du format suivant :
* escape_url est optionnel, cette données (tableau) permet d'indiquer s'il faut ou non ignorer certaines urls lors de l'enrgistrement des données.
*
* var $searches_params = array(
* 'fields' => array('name', 'short_content', 'content', 'slug', 'page_title', 'page_description', 'page_keywords'),
* 'url' => array(
* 'url' => 'controller/action/id::id/slug::slug',
* 'params' => array('slug')
* ),
* 'escape_url' => array('controller/action')
* );
*/
$searchesParams = $this->searches_params;
//Paramètres des champs à indexer
$fieldsToIndex = $searchesParams['fields'];
//Liste des champs à indexes
$urlParams = $searchesParams['url'];
//Paramètres de l'url
if (!isset($searchesParams['escape_url']) || isset($searchesParams['escape_url']) && !in_array($this->controller_action, $searchesParams['escape_url'])) {
$datasToSaveKeys = array_keys($datasToSave);
//Liste des clés des champs du model
$searchesDatas = '';
//Données de recherche
//On parcours les champs à indexer
foreach ($fieldsToIndex as $v) {
//Si la clé à indexer est dans le tableau des données à sauvegarder on concatène à la chaine
if (in_array(':' . $v, $datasToSaveKeys)) {
$searchesDatas .= ' ' . $datasToSave[':' . $v];
}
}
///////////////////////
//Génération de l'url//
$url = $urlParams['url'];
$url = str_replace(':id', $id, $url);
foreach ($urlParams['params'] as $v) {
$url = str_replace(':' . $v, $datasToSave[':' . $v], $url);
}
$url = Router::url($url);
//En cas de mise à jour on supprime l'ancienne valeur
if ($action == "update") {
$this->delete_search_index($id);
}
///////////////////////////////////////
//Sauvegarde des données de recherche//
if ($datasToSave[':online'] == 1) {
$searchDatas = array('model' => get_class($this), 'title' => $datasToSave[':page_title'], 'description' => $datasToSave[':page_description'], 'datas' => strip_tags($searchesDatas), 'url' => $url, 'model_id' => $id);
require_once MODELS . DS . 'search.php';
//Chargement du model
$search = new Search();
$search->save($searchDatas);
unset($search);
//Déchargement du model
}
}
}
示例11: save
public function save()
{
PHPWS_Core::initModClass('search', 'Search.php');
$table = $this->_schedule->getEventTable();
if (!PHPWS_DB::isTable($table)) {
return PHPWS_Error::get(CAL_EVENT_TABLE_MISSING, 'calendar', 'Calendar_Event::save');
}
$db = new PHPWS_DB($table);
$result = $db->saveObject($this);
if (PHPWS_Error::isError($result)) {
return $result;
} elseif (!$this->pid) {
// only save the key if the pid is 0
// ie source event not copy
if (empty($this->key_id)) {
$save_key = true;
} else {
$save_key = false;
}
$key = $this->saveKey();
if (PHPWS_Error::isError($key)) {
PHPWS_Error::log($key);
return false;
}
if ($save_key) {
$db->saveObject($this);
}
/* save search settings */
$search = new Search($this->key_id);
$search->addKeywords($this->summary);
$search->addKeywords($this->location);
$search->addKeywords($this->description);
$search->save();
return true;
}
}
示例12: save
public function save()
{
$db = new PHPWS_DB('blog_entries');
if (empty($this->id)) {
$this->create_date = time();
if (!$this->publish_date) {
$this->publish_date = $this->create_date;
}
if (Current_User::isLogged()) {
$this->author_id = Current_User::getId();
$this->author = Current_User::getDisplayName();
} elseif (empty($this->author)) {
$this->author_id = 0;
$this->author = dgettext('blog', 'Anonymous');
}
}
if (Current_User::isLogged()) {
$this->updater_id = Current_User::getId();
$this->updater = Current_User::getDisplayName();
} elseif (empty($this->updater)) {
$this->updater_id = 0;
$this->updater = dgettext('blog', 'Anonymous');
}
$this->update_date = time();
if (empty($this->entry)) {
$this->entry = '';
}
$result = $db->saveObject($this);
if (PHPWS_Error::isError($result)) {
return $result;
}
$update = !$this->key_id ? true : false;
$this->saveKey();
if ($update) {
$db->saveObject($this);
}
$search = new Search($this->key_id);
$search->resetKeywords();
$search->addKeywords($this->title);
$search->addKeywords($this->summary);
$search->addKeywords($this->entry);
$result = $search->save();
if (PHPWS_Error::isError($result)) {
return $result;
}
return $this->id;
}