Exemplo n.º 1
0
 /**
  * @name query
  * @desc 执行一条SQL语句
  * @param string $sql 要执行的sql语句
  * @return resource
  * @access public
  **/
 public function query($sql)
 {
     $begin_microtime = Debug::getTime();
     try {
         $status = $this->db->query($sql);
     } catch (Exception $e) {
         $this->halt($e, $sql);
         return false;
     }
     Debug::db($this->db_host, $this->db_name, $sql, Debug::getTime() - $begin_microtime, $status);
     return $status;
 }
Exemplo n.º 2
0
 /**
  * Return all batch detail records for given product and warehouse
  *
  *  @param	obj			$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 . self::$_table_element . " 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;
     }
 }
Exemplo n.º 3
0
 /**
  * 数据表 > (所有)字段
  * @return array
  */
 function getFields($pTable)
 {
     $this->db =& self::instance($this->_config);
     $tQuery = $this->db->query("SHOW FULL FIELDS FROM `{$pTable}`");
     return $tQuery ? $tQuery->fetchAll(2) : array();
 }