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


PHP DB::Instance方法代码示例

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


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

示例1: moveStock

 function moveStock($whtransfer, &$errors)
 {
     $data = array();
     $data['stitem_id'] = $this->stitem_id;
     $data['whaction_id'] = $whtransfer->transfer_action;
     $data['process_name'] = 'T';
     $data['process_id'] = $whtransfer->id;
     $data['remarks'] = $this->remarks;
     $data['from_whlocation_id'] = $this->from_whlocation_id;
     $data['to_whlocation_id'] = $this->to_whlocation_id;
     $data['qty'] = $this->transfer_qty;
     $db = DB::Instance();
     $db->StartTrans();
     $transactions = array();
     $transactions = STTransaction::prepareMove($data, $errors);
     if (count($transactions) > 0 && count($errors) == 0) {
         foreach ($transactions as $transaction) {
             if (!$transaction->save($errors)) {
                 $errors[] = 'Error saving transaction';
                 break;
             }
         }
     }
     if (count($errors) > 0) {
         $db->FailTrans();
     } else {
         $db->CompleteTrans();
     }
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:29,代码来源:WHTransferline.php

示例2: __construct

 public function __construct(DB $db = null)
 {
     if ($db == null) {
         $this->db = DB::Instance();
     } else {
         $this->db = $db;
     }
     $config = $this->db->getConfig();
     $this->config = $config[$config['driver']];
     if ($this->table_name == null) {
         $this->table_name = strtolower(get_called_class());
         if (isset($this->config['prefix']) && !empty($this->config['prefix'])) {
             $this->table_name = $this->config['prefix'] . $this->table_name;
         }
     }
     if ($config['driver'] == 'mysql') {
         $this->driver = new Drivers\MySqlDriver();
     } elseif ($config['driver'] == 'sqlite') {
         $this->driver = new Drivers\SQLiteDriver();
     } else {
         $this->driver = new Drivers\DbDriver();
     }
     if (method_exists($this, "init")) {
         $this->init();
     }
 }
开发者ID:nkalush,项目名称:orm,代码行数:26,代码来源:Model.php

示例3: populate

 function populate()
 {
     $orders = new CustomerServiceCollection(new SInvoiceLine());
     $customersales = $orders->getServiceHistory();
     $db =& DB::Instance();
     $types = array('ontime' => 'On Time', 'infull' => 'In Full', 'ontime_infull' => 'On Time / In Full');
     $label = array();
     $type_counter = 0;
     $sales_counter = 0;
     foreach ($types as $key => $title) {
         $data = array();
         $sales_counter = 0;
         foreach ($customersales['previous'] as $period => $value) {
             $data['x'][] = $period;
             $data['y'][] = (double) number_format($value[$key . '%'], 2);
             $label[$type_counter][$sales_counter] = $title . ': ' . number_format($value[$key . '%'], 2);
             $sales_counter++;
         }
         $options['seriesList'][] = array('label' => $title, 'legendEntry' => TRUE, 'data' => $data, 'markers' => array('visible' => TRUE, 'type' => 'circle'));
         $type_counter++;
     }
     $options['type'] = 'line';
     $options['identifier'] = __CLASS__;
     $options['labels'] = $label;
     $this->contents = json_encode($options);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:26,代码来源:CustomerServiceGrapher.php

示例4: getTransferId

 static function getTransferId()
 {
     $db =& DB::Instance();
     $query = "SELECT NEXTVAL('wh_transfer_id_seq') as transfer_id";
     $result = $db->Execute($query);
     return $result->fetchObj();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:WHTransferrule.php

示例5: save

 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     $db = DB::Instance();
     $db->StartTrans();
     if (isset($this->_data['permission'])) {
         $permissions = $this->_data['permission'];
         unset($this->_data['permission']);
     } else {
         $permissions = array();
     }
     if (isset($this->_data['admin'])) {
         $admin = $this->_data['admin'];
         unset($this->_data['admin']);
     } else {
         $admin = array();
     }
     if (parent::save('Role')) {
         $role = $this->saved_model;
         if (isset($this->_data['Role']['users']) && is_array($this->_data['Role']['users'])) {
             $users = $this->_data['Role']['users'];
             Role::setUsers($role, $users, $errors);
             $flash->addErrors($errors);
         }
         if ($role->setPermissions($permissions, $errors) && $role->setAdmin($admin)) {
             $db->CompleteTrans();
             sendTo('Roles', 'index', array('admin'));
         }
     }
     //	$db->FailTrans();
     //	$db->CompleteTrans();
     $this->refresh();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:34,代码来源:RolesController.php

示例6: doLogin

 public function doLogin()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     $db = DB::Instance();
     return $this->gateway->Authenticate(array('username' => $username, 'password' => $password, 'db' => $db));
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:HTMLFormLoginHandler.php

示例7: populate

 function populate()
 {
     $orders = new SInvoiceCollection(new SInvoice());
     $customersales = $orders->getSalesHistory();
     $db =& DB::Instance();
     $param = new GLParams();
     $currency_symbol = utf8_decode($param->base_currency_symbol());
     $options = array();
     $options['header']['text'] = 'Sales this month ' . $param->base_currency_symbol() . $customersales['current']['this_month_to_date']['value'];
     $options['header']['text'] .= ' : this week ' . $param->base_currency_symbol() . $customersales['current']['this_week']['value'];
     $options['header']['text'] .= ' : last week ' . $param->base_currency_symbol() . $customersales['current']['last_week']['value'];
     $options['header']['textStyle']['font-size'] = '14pt';
     ksort($customersales['previous']);
     $options['date_axis'] = TRUE;
     $sales_counter = 0;
     // build up data array
     foreach ($customersales['previous'] as $period => $value) {
         $date = explode('/', $period);
         $data['x'][] = $date[1] . "/1/" . $date[0];
         $data['y'][] = (double) $value['value'];
         $label[0][$sales_counter++] = number_format($value['value'], 2);
     }
     $options['seriesList'][] = array('legendEntry' => FALSE, 'data' => $data, 'date_axis' => array('x' => TRUE), 'markers' => array('visible' => TRUE, 'type' => 'circle'));
     $options['type'] = 'line';
     $options['identifier'] = __CLASS__;
     $options['labels'] = $label;
     $this->contents = json_encode($options);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:28,代码来源:SalesHistoryGrapher.php

示例8: _new

 public function _new()
 {
     parent::_new();
     $resource = $this->_uses[$this->modeltype];
     $db = DB::Instance();
     if ($resource->isLoaded()) {
         $this->_data['work_schedule_id'] = $resource->work_schedule_id;
         $this->view->set('workschedule', $resource->work_schedule_detail);
     } elseif (isset($this->_data['work_schedule_id'])) {
         $resource->work_schedule_id = $this->_data['work_schedule_id'];
         $this->view->set('workschedule', $resource->work_schedule_detail);
     } else {
         $workschedule = DataObjectFactory::Factory('WorkSchedule');
         $cc = new ConstraintChain();
         $cc->add(new Constraint('status', '!=', $workschedule->completedStatus()));
         $cc->add(new Constraint('status', '!=', $workschedule->cancelledStatus()));
         $this->view->set('workschedules', $workschedule->getAll($cc));
     }
     $person = DataObjectFactory::Factory('Person');
     $cc = new ConstraintChain();
     $cc->add(new Constraint('company_id', '=', COMPANY_ID));
     $this->view->set('people', $person->getAll($cc));
     $resources = new EngineeringResourceCollection($this->_templateobject);
     $sh = $this->setSearchHandler($resources);
     $sh->addConstraint(new Constraint('work_schedule_id', '=', $resource->work_schedule_id));
     parent::index($resources, $sh);
     $this->view->set('clickaction', 'edit');
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:28,代码来源:EngineeringresourcesController.php

示例9: handle

 function handle(DataObject $model)
 {
     $db = DB::Instance();
     $query = "SELECT id FROM glperiods WHERE enddate > now() ORDER BY enddate DESC LIMIT 1";
     $return = $db->GetOne($query);
     return intval($return);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:CurrentPeriodHandler.php

示例10: load

 function load($sh, $c_query = null)
 {
     $db = DB::Instance();
     $qb = new QueryBuilder($db, $this->_doname);
     if ($sh instanceof SearchHandler) {
         if ($this->_templateobject->isAccessControlled()) {
             if (isModuleAdmin()) {
                 $cc = new ConstraintChain();
                 $cc->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
                 $cc->add(new Constraint('id', '=', EGS_COMPANY_ID), 'OR');
                 $sh->addConstraintChain($cc);
                 $qb->setDistinct();
             } else {
                 $cc = new ConstraintChain();
                 $cc->add(new Constraint('usernameaccess', '=', EGS_USERNAME));
                 $cc->add(new Constraint('owner', '=', EGS_USERNAME), 'OR');
                 $cc2 = new ConstraintChain();
                 $cc2->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
                 $sh->addConstraintChain($cc);
                 $sh->addConstraintChain($cc2);
                 $qb->setDistinct();
             }
         }
         $this->sh = $sh;
     }
     $this->_load($sh, $qb, $c_query);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:27,代码来源:PersonCollection.php

示例11: toConstraint

 /**
  * @param void
  * @return Constraint
  *
  * Produces a Constraint between two dates
  */
 public function toConstraint()
 {
     $db = DB::Instance();
     $c = false;
     $to = '';
     $from = '';
     if ($this->value_set) {
         $from = $this->value['from'];
         $to = $this->value['to'];
     } else {
         $from = $this->default['from'];
         $to = $this->default['to'];
     }
     switch ($this->type) {
         case 'between':
             if (!empty($from)) {
                 if (!empty($to)) {
                     $c = new Constraint($this->fieldname, 'between', $db->qstr(fix_date($from)) . ' and ' . $db->qstr(fix_date($to)));
                 } else {
                     $c = new Constraint($this->fieldname, '>=', $db->qstr(fix_date($from)));
                 }
             } else {
                 if (!empty($to)) {
                     $c = new Constraint($this->fieldname, '<=', $db->qstr(fix_date($to)));
                 }
             }
             break;
     }
     return $c;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:36,代码来源:TwoDateSearchField.php

示例12: revalue

 function revalue($data, &$errors = array())
 {
     if (empty($data['transaction_date'])) {
         $data['transaction_date'] = date(DATE_FORMAT);
     }
     $glperiod = GLPeriod::getPeriod(fix_date($data['transaction_date']));
     if (!$glperiod || count($glperiod) == 0) {
         $errors[] = 'No period exists for this date';
         return false;
     }
     $data['value'] = bcsub($this->glbalance(), $data['new_balance']);
     $data['glperiods_id'] = $glperiod['id'];
     $data['source'] = 'C';
     $data['type'] = 'V';
     $data['glaccount_id'] = $this->currency_detail->writeoff_glaccount_id;
     $data['glcentre_id'] = $this->currency_detail->glcentre_id;
     GLTransaction::setTwinCurrency($data);
     $gl_trans[] = GLTransaction::Factory($data, $errors);
     $data['value'] = bcmul($data['value'], -1);
     $data['glaccount_id'] = $this->glaccount_id;
     $data['glcentre_id'] = $this->glcentre_id;
     GLTransaction::setTwinCurrency($data);
     $gl_trans[] = GLTransaction::Factory($data, $errors);
     $db = DB::Instance();
     $db->StartTrans();
     if (count($errors) == 0 && GLTransaction::saveTransactions($gl_trans, $errors)) {
         return $db->CompleteTrans();
     }
     $errors[] = 'Failed to save GL Transaction';
     $db->FailTrans();
     $db->CompleteTrans();
     return false;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:33,代码来源:CBAccount.php

示例13: handle

 function handle(DataObject $model)
 {
     $db = DB::Instance();
     $query = 'SELECT max(complaint_number) FROM ' . $model->getTableName() . ' WHERE usercompanyid=' . EGS_COMPANY_ID . ' AND "type"=' . $db->qstr($model->type);
     $current = $db->GetOne($query);
     return $current + 1;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:ComplaintNumberHandler.php

示例14: getFromUoM

 function getFromUoM($from_uom_id)
 {
     $db = DB::Instance();
     $query = "select uom_name from st_uoms where id=" . $db->qstr($from_uom_id);
     $getFromUoM = $db->GetOne($query);
     return $getFromUoM;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:STuomconversion.php

示例15: GetCurPageParams

function GetCurPageParams()
{
    $PageId = ToolMethod::Instance()->GetPageId();
    $sql = "select PageId,ParamsId,ParamsType,ParamsName,FieldsId,FieldsName\n\t\t\tfrom config_page_param\n\t\t\twhere PageId='" . $PageId . "'";
    $tmp = DB::Instance()->GetFirstRow($sql);
    $ParamsId = explode(",", $tmp["ParamsId"]);
    // , 隔开
    $ParamsType = explode(",", $tmp["ParamsType"]);
    $ParamsName = explode(",", $tmp["ParamsName"]);
    $FieldsId = explode(",", $tmp["FieldsId"]);
    $FieldsName = explode(",", $tmp["FieldsName"]);
    if (count($ParamsId) == count($ParamsType) && count($ParamsId) == count($ParamsName) && count($ParamsType) == count($ParamsName) && count($FieldsId) == count($FieldsName)) {
        $sql = "select tb2.BtnId,tb2.BtnClass,tb2.BtnName,tb2.BtnIcon\n\t\t\t\tfrom(\n\t\t\t\t     select * from config_page_btn\n\t\t\t\t     where IsActive=1 and PageId='" . $PageId . "'\n\t\t\t\t     order by Seq\n\t\t\t\t) as tb1\n\t\t\t\tinner join(\n\t\t\t\t     select * from config_btn\n\t\t\t\t     where IsActive=1\n\t\t\t\t) as tb2\n\t\t\t\ton tb1.BtnId=tb2.BtnId";
        $tmp_Btn = DB::Instance()->GetJson($sql);
        $tmp_Params = "";
        for ($i = 0; $i < count($ParamsId); $i++) {
            if ($ParamsId[$i] != "" && $ParamsType[$i] != "" && $ParamsName[$i] != "") {
                $tmp_Params .= '{' . '"id":' . json_encode($ParamsId[$i]) . ',' . '"type":' . json_encode($ParamsType[$i]) . ',' . '"name":' . json_encode($ParamsName[$i]) . '' . '},';
            }
        }
        $tmp_Params = rtrim($tmp_Params, ",");
        $tmp_Fields = "";
        for ($i = 0; $i < count($FieldsId); $i++) {
            if ($FieldsId[$i] != "" && $FieldsName[$i] != "") {
                $tmp_Fields .= '{' . '"id":' . json_encode($FieldsId[$i]) . ',' . '"name":' . json_encode($FieldsName[$i]) . '' . '},';
            }
        }
        $tmp_Fields = rtrim($tmp_Fields, ",");
        echo '{' . '"PageId":' . json_encode($PageId) . ',' . '"Params":[' . $tmp_Params . '],' . '"Fields":[' . $tmp_Fields . '],' . '"Btns":' . $tmp_Btn . '' . '}';
    } else {
        throw new Exception("Params Error");
        //配置失败
    }
}
开发者ID:TyroCCC,项目名称:ERP_Test,代码行数:34,代码来源:Env.php


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