Beispiel #1
0
 /**
  * Adapter constructor
  *
  * @param array $config
  */
 public function __construct($config)
 {
     $phql = $config['phql'];
     $bind = $config['bind'];
     $page = $config['page'];
     $limit = $config['limit'];
     $phql .= " LIMIT {$limit} OFFSET " . ($page - 1) * $limit;
     $query = new \Phalcon\Mvc\Model\Query($phql);
     $query->setDI($config['di']);
     $this->data = $query->execute($bind);
 }
 function creatOrder(&$order_id, $raise_id, $wheel_id, $user_id, $params)
 {
     $flag = false;
     try {
         $this->di['db']->begin();
         $nowtime = time();
         $order = new DtbProjectInvestOrder();
         $order->invest_money = $params['invest_money'];
         $order->equit_offered = $params['equit_offered'];
         $order->service_fee = $params['service_fee'];
         $order->raise_id = $raise_id;
         $order->user_id = $user_id;
         $order->bond = $params['bond'];
         $order->invite_code = $params['invite_code'];
         $order->real_pay_fee = $params['real_pay_fee'];
         //?
         $order->create_ts = $nowtime;
         $order->update_ts = $nowtime;
         $order->wheel_id = $wheel_id;
         $order->result = 0;
         if (!$order->create()) {
             foreach ($order->getMessages() as $message) {
                 echo $message;
             }
             $this->di['db']->rollback();
             return $flag;
         } else {
             $action_type = $this->di['config']->log_user->createorder;
             $log_ts = time();
             $sql = "insert into DtbLogUser (user_id,action_type,log_ts) values('{$user_id}','{$action_type}','{$log_ts}' )";
             $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
             $res1 = $query->execute();
             if (!$res1) {
                 $this->di['db']->rollback();
             } else {
                 $flag = true;
                 $this->di['db']->commit();
                 $order_id = $order->getOrderId();
             }
             return $flag;
         }
     } catch (Exception $ex) {
         $this->di['db']->rollback();
         return $flag;
     }
 }
 public function applyPerson($user_id, $params)
 {
     $flag = false;
     try {
         $this->di['db']->begin();
         $invest_person = new DtbInvestorPerson();
         $invest_person->user_id = $user_id;
         $invest_person->address = $params['address'];
         $invest_person->real_name = $params['real_name'];
         $invest_person->identity_card = isset($params['identity_card']) ? $params['identity_card'] : null;
         $invest_person->idc_img1 = isset($params['idc_img1']) ? $params['idc_img1'] : null;
         $invest_person->idc_img2 = isset($params['idc_img2']) ? $params['idc_img2'] : null;
         $invest_person->province = $params['province'];
         $invest_person->city = $params['city'];
         $invest_person->dist = $params['dist'];
         $invest_person->income_y = isset($params['income_y']) ? $params['income_y'] : 0;
         $invest_person->company = $params['company'];
         $invest_person->position = $params['position'];
         $invest_person->person_fund = isset($params['person_fund']) ? $params['person_fund'] : 0;
         $invest_person->available_extra_price = isset($params['available_extra_price']) ? $params['available_extra_price'] : 0;
         $invest_person->singel_invest_range = isset($params['singel_invest_range']) ? $params['singel_invest_range'] : 0;
         $invest_person->invest_exp = $params['invest_exp'];
         $invest_person->attention_direct = $params['attention_direct'];
         $invest_person->invest_idea = $params['invest_idea'];
         $invest_person->available_extra_price = $params['available_extra_price'];
         $invest_person->create_ts = time();
         $invest_person->update_ts = time();
         $invest_person->country = $params['country'];
         $invest_person->result = 0;
         if (!$invest_person->create()) {
             foreach ($invest_person->getMessages() as $message) {
                 echo $message;
             }
             $this->di['db']->rollback();
             return $flag;
         } else {
             $action_type = $this->di['config']->log_user->applyperson;
             $log_ts = time();
             $sql = "insert into DtbLogUser (user_id,action_type,log_ts) values('{$user_id}','{$action_type}','{$log_ts}' )";
             $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
             $res1 = $query->execute();
             $sql = "update  DtbUserBasic set account_type=2 where user_id={$user_id} and account_type=0";
             $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
             $res2 = $query->execute();
             if (!$res1) {
                 $this->di['db']->rollback();
             } else {
                 if (!$res2) {
                     $this->di['db']->rollback();
                 } else {
                     $flag = true;
                     $this->di['db']->commit();
                 }
             }
             return $flag;
         }
     } catch (Exception $ex) {
         $this->di['db']->rollback();
         return $flag;
     }
 }
Beispiel #4
0
<?php

// Instantiate the Query
$query = new Phalcon\Mvc\Model\Query("SELECT * FROM Cars");
// Pass the DI container
$query->setDI($di);
// Execute the query returning a result if any
$cars = $query->execute();
Beispiel #5
0
<?php

// Instantiate the Query
$query = new Phalcon\Mvc\Model\Query("SELECT * FROM Cars", $di);
// Execute the query returning a result if any
$cars = $query->execute();
 public function getSuccessProject($limit)
 {
     $sql = "select DtbRaiseProjectBasic.company,DtbRaiseProjectBasic.company_logo,DtbRaiseProjectBasic.project_name,DtbRaiseProjectWheel.already_money,DtbRaiseProjectWheel.wheel_invested_num from DtbRaiseProjectBasic,DtbRaiseProjectWheel where DtbRaiseProjectWheel.status=1  and DtbRaiseProjectBasic.now_wheel_id=DtbRaiseProjectWheel.wheel_id order by DtbRaiseProjectWheel.end_ts,DtbRaiseProjectWheel.already_money desc  limit {$limit}";
     //var_dump($this->getDI());
     $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
     return $res = $query->execute();
 }