当前位置: 首页>>代码示例>>PHP>>正文


PHP DoliDB::lasterror方法代码示例

本文整理汇总了PHP中DoliDB::lasterror方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::lasterror方法的具体用法?PHP DoliDB::lasterror怎么用?PHP DoliDB::lasterror使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoliDB的用法示例。


在下文中一共展示了DoliDB::lasterror方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findAll

 /**
  * Return all batch detail records for given product and warehouse
  *
  *  @param	DoliDB		$db    				database object
  *  @param	int			$fk_product_stock	id product_stock for objet
  *  @param	int			$with_qty    		doesn't return line with 0 quantity
  *  @return int         					<0 if KO, >0 if OK
  */
 public static function findAll($db, $fk_product_stock, $with_qty = 0)
 {
     global $langs;
     $ret = array();
     $sql = "SELECT";
     $sql .= " t.rowid,";
     $sql .= " t.tms,";
     $sql .= " t.fk_product_stock,";
     $sql .= " t.sellby,";
     $sql .= " t.eatby,";
     $sql .= " t.batch,";
     $sql .= " t.qty,";
     $sql .= " t.import_key";
     $sql .= " FROM " . MAIN_DB_PREFIX . "product_batch as t";
     $sql .= " WHERE fk_product_stock=" . $fk_product_stock;
     if ($with_qty) {
         $sql .= " AND qty<>0";
     }
     dol_syslog("productbatch::findAll", LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $num = $db->num_rows($resql);
         $i = 0;
         while ($i < $num) {
             $obj = $db->fetch_object($resql);
             $tmp = new productbatch($db);
             $tmp->id = $obj->rowid;
             $tmp->tms = $db->jdate($obj->tms);
             $tmp->fk_product_stock = $obj->fk_product_stock;
             $tmp->sellby = $db->jdate($obj->sellby);
             $tmp->eatby = $db->jdate($obj->eatby);
             $tmp->batch = $obj->batch;
             $tmp->qty = $obj->qty;
             $tmp->import_key = $obj->import_key;
             array_push($ret, $tmp);
             $i++;
         }
         $db->free($resql);
         return $ret;
     } else {
         $error = "Error " . $db->lasterror();
         return -1;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:52,代码来源:productbatch.class.php

示例2: getLabelFromKey

 /**
  *      Return a label for a key.
  *      Search into translation array, then into cache, then if still not found, search into database.
  *      Store key-label found into cache variable $this->cache_labels to save SQL requests to get labels.
  *
  * 		@param	DoliDB	$db				Database handler
  * 		@param	string	$key			Translation key to get label (key in language file)
  * 		@param	string	$tablename		Table name without prefix
  * 		@param	string	$fieldkey		Field for key
  * 		@param	string	$fieldlabel		Field for label
  *      @param	string	$keyforselect	Use another value than the translation key for the where into select
  *      @return string					Label in UTF8 (but without entities)
  *      @see dol_getIdFromCode
  */
 function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '')
 {
     // If key empty
     if ($key == '') {
         return '';
     }
     //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
     // Check if a translation is available (this can call getTradFromKey)
     if ($this->transnoentitiesnoconv($key) != $key) {
         return $this->transnoentitiesnoconv($key);
         // Found in language array
     }
     // Check in cache
     if (isset($this->cache_labels[$tablename][$key])) {
         return $this->cache_labels[$tablename][$key];
         // Found in cache
     }
     $sql = "SELECT " . $fieldlabel . " as label";
     $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
     $sql .= " WHERE " . $fieldkey . " = '" . ($keyforselect ? $keyforselect : $key) . "'";
     dol_syslog(get_class($this) . '::getLabelFromKey', LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $obj = $db->fetch_object($resql);
         if ($obj) {
             $this->cache_labels[$tablename][$key] = $obj->label;
         } else {
             $this->cache_labels[$tablename][$key] = $key;
         }
         $db->free($resql);
         return $this->cache_labels[$tablename][$key];
     } else {
         $this->error = $db->lasterror();
         return -1;
     }
 }
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:50,代码来源:translate.class.php

示例3: listBoxes


//.........这里部分代码省略.........
         if ($zone >= 0) {
             $sql .= " AND b.position = " . $zone;
         }
         if (is_object($user)) {
             $sql .= " AND b.fk_user IN (0," . $user->id . ")";
         } else {
             $sql .= " AND b.fk_user = 0";
         }
         $sql .= " ORDER BY b.box_order";
     } else {
         $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
         $sql .= " FROM " . MAIN_DB_PREFIX . "boxes_def as d";
         $sql .= " WHERE d.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) ? "1," : "") . $conf->entity . ")";
     }
     dol_syslog(get_class() . "::listBoxes get default box list for mode=" . $mode . " userid=" . (is_object($user) ? $user->id : '') . "", LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $num = $db->num_rows($resql);
         $j = 0;
         while ($j < $num) {
             $obj = $db->fetch_object($resql);
             if (!in_array($obj->box_id, $excludelist)) {
                 if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) {
                     $boxname = preg_replace('/\\.php$/i', '', $regs[1]);
                     $module = $regs[2];
                     $relsourcefile = "/" . $module . "/core/boxes/" . $boxname . ".php";
                 } else {
                     $boxname = preg_replace('/\\.php$/i', '', $obj->file);
                     $relsourcefile = "/core/boxes/" . $boxname . ".php";
                 }
                 //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>';
                 // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then
                 // the "enabled" condition for modules forbidden for external users and the depends condition can be done.
                 // Goal is to avoid making a "new" done for each boxes returned by select.
                 dol_include_once($relsourcefile);
                 if (class_exists($boxname)) {
                     $box = new $boxname($db, $obj->note);
                     // Constructor may set properties like box->enabled. obj->note is note into box def, not user params.
                     //$box=new stdClass();
                     // box properties
                     $box->rowid = empty($obj->rowid) ? '' : $obj->rowid;
                     $box->id = empty($obj->box_id) ? '' : $obj->box_id;
                     $box->position = $obj->position == '' ? '' : $obj->position;
                     // '0' must staty '0'
                     $box->box_order = empty($obj->box_order) ? '' : $obj->box_order;
                     $box->fk_user = empty($obj->fk_user) ? 0 : $obj->fk_user;
                     $box->sourcefile = $relsourcefile;
                     $box->class = $boxname;
                     if ($mode == 'activated' && !is_object($user)) {
                         if (is_numeric($box->box_order)) {
                             if ($box->box_order % 2 == 1) {
                                 $box->box_order = 'A' . $box->box_order;
                             } elseif ($box->box_order % 2 == 0) {
                                 $box->box_order = 'B' . $box->box_order;
                             }
                         }
                     }
                     // box_def properties
                     $box->box_id = empty($obj->box_id) ? '' : $obj->box_id;
                     $box->note = empty($obj->note) ? '' : $obj->note;
                     // Filter on box->enabled (used for example by box_comptes)
                     // Filter also on box->depends. Example: array("product|service") or array("contrat", "service")
                     $enabled = $box->enabled;
                     if (isset($box->depends) && count($box->depends) > 0) {
                         foreach ($box->depends as $moduleelem) {
                             $arrayelem = explode('|', $moduleelem);
                             $tmpenabled = 0;
                             // $tmpenabled is used for the '|' test (OR)
                             foreach ($arrayelem as $module) {
                                 $tmpmodule = preg_replace('/@[^@]+/', '', $module);
                                 if (!empty($conf->{$tmpmodule}->enabled)) {
                                     $tmpenabled = 1;
                                 }
                                 //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
                             }
                             if (empty($tmpenabled)) {
                                 $enabled = 0;
                                 break;
                             }
                         }
                     }
                     //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
                     //print 'xx module='.$module.' enabled='.$enabled;
                     if ($enabled) {
                         $boxes[] = $box;
                     } else {
                         unset($box);
                     }
                 } else {
                     dol_syslog("Failed to load box '" . $boxname . "' into file '" . $relsourcefile . "'", LOG_WARNING);
                 }
             }
             $j++;
         }
     } else {
         dol_syslog($db->lasterror(), LOG_ERR);
         return array('error' => $db->lasterror());
     }
     return $boxes;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:infobox.class.php

示例4: dol_getIdFromCode

/**
 *      Return an id or code from a code or id. Store Code-Id in a cache.
 *
 * 		@param	DoliDB	$db			Database handler
 * 		@param	string	$key		Code to get Id
 * 		@param	string	$tablename	Table name without prefix
 * 		@param	string	$fieldkey	Field for code
 * 		@param	string	$fieldid	Field for id
 *      @return int					Id of code
 */
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id')
{
    global $cache_codes;
    // If key empty
    if ($key == '') {
        return '';
    }
    // Check in cache
    if (isset($cache_codes[$tablename][$key])) {
        // Can be defined to 0 or ''
        return $cache_codes[$tablename][$key];
        // Found in cache
    }
    $sql = "SELECT " . $fieldid . " as id";
    $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
    $sql .= " WHERE " . $fieldkey . " = '" . $key . "'";
    dol_syslog('dol_getIdFromCode sql=' . $sql, LOG_DEBUG);
    $resql = $db->query($sql);
    if ($resql) {
        $obj = $db->fetch_object($resql);
        if ($obj) {
            $cache_codes[$tablename][$key] = $obj->id;
        } else {
            $cache_codes[$tablename][$key] = '';
        }
        $db->free($resql);
        return $cache_codes[$tablename][$key];
    } else {
        dol_syslog("dol_getIdFromCode error=" . $db->lasterror(), LOG_ERR);
        return -1;
    }
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:42,代码来源:functions.lib.php


注:本文中的DoliDB::lasterror方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。