本文整理汇总了PHP中Categorie::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Categorie::fetch方法的具体用法?PHP Categorie::fetch怎么用?PHP Categorie::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Categorie
的用法示例。
在下文中一共展示了Categorie::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete category
*
* @param int $id Category ID
* @return array
*
* @url DELETE category/{id}
*/
function delete($id)
{
if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if (!$result) {
throw new RestException(404, 'category not found');
}
if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
}
if (!$this->category->delete(DolibarrApiAccess::$user)) {
throw new RestException(401, 'error when delete category');
}
return array('success' => array('code' => 200, 'message' => 'Category deleted'));
}
示例2: _categories
function _categories($fk_parent = 0, $keyword = '')
{
global $db, $conf;
$TFille = array();
if (!empty($keyword)) {
$resultset = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie WHERE label LIKE '%" . addslashes($keyword) . "%' ORDER BY label");
while ($obj = $db->fetch_object($resultset)) {
$cat = new Categorie($db);
$cat->fetch($obj->rowid);
$TFille[] = $cat;
}
} else {
$parent = new Categorie($db);
if (empty($fk_parent)) {
if (empty($conf->global->SPC_DO_NOT_LOAD_PARENT_CAT)) {
$TFille = $parent->get_all_categories(0, true);
}
} else {
$parent->fetch($fk_parent);
$TFille = $parent->get_filles();
}
}
return $TFille;
}
示例3: setCategories
/**
* Sets object to supplied categories.
*
* Deletes object from existing categories not supplied.
* Adds it to non existing supplied categories.
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
*/
public function setCategories($categories)
{
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array();
// Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
$c->fetch($del);
$c->del_type($this, 'product');
}
foreach ($to_add as $add) {
$c->fetch($add);
$c->add_type($this, 'product');
}
return;
}
示例4: testCategorieDelete
/**
* @depends testCategorieOther
* The depends says test is run only if previous is ok
*/
public function testCategorieDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Categorie($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
示例5: llxHeader
$texte = $langs->trans("Products");
}
} else {
$texte = $langs->trans("ProductsAndServices");
}
$texte .= ' (' . $langs->trans("Stocks") . ')';
llxHeader("", $texte, $helpurl);
if ($sref || $snom || $sall || GETPOST('search')) {
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=" . $sref . "&snom=" . $snom . "&sall=" . $sall . "&tosell=" . $tosell . "&tobuy=" . $tobuy . (!empty($search_categ) ? '&search_categ=' . $search_categ : '') . (!empty($toolowstock) ? '&toolowstock=' . $toolowstock : ''), $sortfield, $sortorder, '', $num);
} else {
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref={$sref}&snom={$snom}&fourn_id={$fourn_id}" . (isset($type) ? "&type={$type}" : "") . (!empty($search_categ) ? '&search_categ=' . $search_categ : '') . (!empty($toolowstock) ? '&toolowstock=' . $toolowstock : ''), $sortfield, $sortorder, '', $num);
}
if (!empty($catid)) {
print "<div id='ways'>";
$c = new Categorie($db);
$c->fetch($catid);
$ways = $c->print_all_ways(' > ', 'product/reassort.php');
print " > " . $ways[0] . "<br>\n";
print "</div><br>";
}
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formulaire">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
print '<input type="hidden" name="type" value="' . $type . '">';
print '<table class="liste" width="100%">';
// Filter on categories
$moreforfilter = '';
if (!empty($conf->categorie->enabled)) {
$moreforfilter .= $langs->trans('Categories') . ': ';
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ');
示例6: header
if ($categorie->update($user) > 0) {
header('Location: ' . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $categorie->id . '&type=' . $type);
exit;
} else {
setEventMessage($categorie->error, 'errors');
}
} else {
setEventMessage($categorie->error, 'errors');
}
}
/*
* View
*/
llxHeader("", "", $langs->trans("Categories"));
print_fiche_titre($langs->trans("ModifCat"));
$object->fetch($id);
$form = new Form($db);
print '<table class="notopnoleft" border="0" width="100%">';
print '<tr><td class="notopnoleft" valign="top" width="30%">';
print "\n";
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="type" value="' . $type . '">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="fieldrequired">';
print $langs->trans("Ref") . '</td>';
print '<td><input type="text" size="25" id="nom" name ="nom" value="' . $object->label . '" />';
print '</tr>';
示例7: rechercher
/**
* Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
*
* @param int $id Id
* @param string $nom Name
* @param string $type Type
* @param boolean $exact Ture or false
* @return array Array of category id
*/
function rechercher($id, $nom, $type, $exact = false)
{
$cats = array();
// Generation requete recherche
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
$sql .= " WHERE type = " . $type . " ";
$sql .= " AND entity IN (" . getEntity('category', 1) . ")";
if ($nom) {
if (!$exact) {
$nom = '%' . str_replace('*', '%', $nom) . '%';
}
$sql .= "AND label LIKE '" . $nom . "'";
}
if ($id) {
$sql .= "AND rowid = '" . $id . "'";
}
$res = $this->db->query($sql);
if ($res) {
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[] = $cat;
}
return $cats;
} else {
$this->error = $this->db->error() . ' sql=' . $sql;
dol_syslog("Categorie::rechercher " . $this->error, LOG_ERR);
return -1;
}
}
示例8: Societe
}
if ($_REQUEST["type"]==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$type = 'societe';
}
if ($_REQUEST["type"]==3 && $user->rights->adherent->creer)
{
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
$object = new Adherent($db);
$result = $object->fetch($objectid);
$type = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["catMere"]);
$result=$cat->add_type($object,$type);
if ($result >= 0)
{
$mesg='<div class="ok">'.$langs->trans("WasAddedSuccessfully",$cat->label).'</div>';
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="warning">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>';
}
}
示例9: GETPOST
$langs->load("categories");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref');
$type = GETPOST('type');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$removeelem = GETPOST('removeelem', 'int');
$elemid = GETPOST('elemid');
if ($id == "") {
dol_print_error('', 'Missing parameter id');
exit;
}
// Security check
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
$result = $object->fetch($id);
$object->fetch_optionals($id, $extralabels);
if ($result <= 0) {
dol_print_error($db, $object->error);
exit;
}
$type = $object->type;
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/
// Remove element from category
if ($id > 0 && $removeelem > 0) {
示例10: rechercher
/**
* Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
*
* @param int $id Id
* @param string $nom Name
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated.
* @param boolean $exact Exact string search (true/false)
* @param boolean $case Case sensitive (true/false)
* @return array Array of category id
*/
function rechercher($id, $nom, $type, $exact = false, $case = false)
{
// Deprecation warning
if (is_numeric($type)) {
dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING);
}
$cats = array();
// For backward compatibility
if (is_numeric($type)) {
// We want to reverse lookup
$map_type = array_flip($this->MAP_ID);
$type = $map_type;
dol_syslog(get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING);
}
// Generation requete recherche
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
$sql .= " WHERE type = " . $this->MAP_ID[$type];
$sql .= " AND entity IN (" . getEntity('category', 1) . ")";
if ($nom) {
if (!$exact) {
$nom = '%' . str_replace('*', '%', $nom) . '%';
}
if (!$case) {
$sql .= " AND label LIKE '" . $this->db->escape($nom) . "'";
} else {
$sql .= " AND label LIKE BINARY '" . $this->db->escape($nom) . "'";
}
}
if ($id) {
$sql .= " AND rowid = '" . $id . "'";
}
$res = $this->db->query($sql);
if ($res) {
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[] = $cat;
}
return $cats;
} else {
$this->error = $this->db->error() . ' sql=' . $sql;
return -1;
}
}
示例11: setCategories
/**
* Sets object to supplied categories.
*
* Deletes object from existing categories not supplied.
* Adds it to non existing supplied categories.
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
* @param string $type Category type (customer or supplier)
*/
public function setCategories($categories, $type)
{
// Decode type
if ($type == 'customer') {
$type_id = Categorie::TYPE_CUSTOMER;
$type_text = 'customer';
} elseif ($type == 'supplier') {
$type_id = Categorie::TYPE_SUPPLIER;
$type_text = 'supplier';
} else {
dol_syslog(__METHOD__ . ': Type ' . $type . 'is an unknown company category type. Done nothing.', LOG_ERR);
return;
}
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_id, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, $type_text);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, $type_text);
}
}
return;
}
示例12: rechercher
/**
* Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
*
* @param int $id Id
* @param string $nom Name
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated.
* @param boolean $exact Exact string search (true/false)
* @param boolean $case Case sensitive (true/false)
* @return array Array of category id
*/
function rechercher($id, $nom, $type, $exact = false, $case = false)
{
$cats = array();
$typeid = -1;
if ($type == 0 || $type == 'product') {
$typeid = 0;
} else {
if ($type == 1 || $type == 'supplier') {
$typeid = 1;
} else {
if ($type == 2 || $type == 'customer') {
$typeid = 2;
} else {
if ($type == 3 || $type == 'member') {
$typeid = 3;
} else {
if ($type == 4 || $type == 'contact') {
$typeid = 4;
}
}
}
}
}
// Generation requete recherche
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
$sql .= " WHERE type = " . $typeid;
$sql .= " AND entity IN (" . getEntity('category', 1) . ")";
if ($nom) {
if (!$exact) {
$nom = '%' . str_replace('*', '%', $nom) . '%';
}
if (!$case) {
$sql .= " AND label LIKE '" . $this->db->escape($nom) . "'";
} else {
$sql .= " AND label LIKE BINARY '" . $this->db->escape($nom) . "'";
}
}
if ($id) {
$sql .= " AND rowid = '" . $id . "'";
}
$res = $this->db->query($sql);
if ($res) {
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[] = $cat;
}
return $cats;
} else {
$this->error = $this->db->error() . ' sql=' . $sql;
return -1;
}
}
示例13: Adherent
$elementtype = 'societe';
}
if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) {
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$object = new Contact($db);
$result = $object->fetch($objectid);
$elementtype = 'contact';
}
$cat = new Categorie($db);
$result = $cat->fetch($parent);
$result = $cat->add_type($object, $elementtype);
if ($result >= 0) {
setEventMessages($langs->trans("WasAddedSuccessfully", $cat->label), null, 'mesgs');
} else {
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
} else {
setEventMessages($cat->error, $cat->errors, 'errors');
}
}
}
}
/*
* View
*/
示例14: lead
$result = $object->fetch($objectid);
$elementtype = 'member';
}
if ($_REQUEST["type"] == 4 && $user->rights->lead->creer) {
require_once DOL_DOCUMENT_ROOT . "/lead/class/lead.class.php";
$object = new lead($db);
$result = $object->fetch($objectid);
$type = 'lead';
}
if ($_REQUEST["type"] == 5 && $user->rights->societe->creer) {
require_once DOL_DOCUMENT_ROOT . "/contact/class/contact.class.php";
$object = new Contact($db);
$result = $object->fetch($objectid);
}
$cat = new Categorie($db);
$result = $cat->fetch($catMere);
$result = $cat->add_type($object, $elementtype);
if ($result >= 0) {
$mesg = '<div class="ok">' . $langs->trans("WasAddedSuccessfully", $cat->label) . '</div>';
if ($_REQUEST["type"] == 2) {
$actioncomm = new ActionComm($db);
$actioncomm->addAutoTask('AC_QUALIF', "Qualification prospect/client/contact : " . $cat->label, $_GET["socid"], '', '');
}
if ($_REQUEST["type"] == 5) {
$actioncomm = new ActionComm($db);
$actioncomm->addAutoTask('AC_QUALIF', "Qualification prospect/client/contact : " . $cat->label, $object->socid, '', '', $object->id);
}
} else {
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$mesg = '<div class="error">' . $langs->trans("ObjectAlreadyLinkedToCategory") . '</div>';
} else {
示例15: getCategorybyId
/**
* Return a catergory
* @param int $idCat Id of Category
* @return array Category info
*/
public static function getCategorybyId($idCat)
{
global $db;
$objCat = new Categorie($db);
$result = $objCat->fetch($idCat);
if ($result > 0) {
return $objCat;
}
return -1;
}