function setUp()
  {
    $this->db =& DbFactory :: instance();
    $this->links_manager = new LinksManager();

    $this->_cleanUp();
  }
  function setUp()
  {
    $this->mapper = new SiteObjectBehaviourMapper();
    $this->db = DbFactory :: instance();

    $this->_cleanUp();
  }
  function setUp()
  {
    parent :: setUp();

    $this->db =& DbFactory :: instance();

    $tree = Limb :: toolkit()->getTree();

    $values['identifier'] = 'root';
    $this->node_id_root = $tree->createRootNode($values, false, true);

    $values['identifier'] = 'ru';
    $values['object_id'] = 1;
    $this->node_id_ru = $tree->createSubNode($this->node_id_root, $values);

    $values['identifier'] = 'document';
    $values['object_id'] = 10;
    $this->node_id_document = $tree->createSubNode($this->node_id_ru, $values);

    $values['identifier'] = 'doc1';
    $values['object_id'] = 20;
    $this->node_id_doc1 = $tree->createSubNode($this->node_id_ru, $values);

    $values['identifier'] = 'doc2';
    $values['object_id'] = 30;
    $this->node_id_doc2 = $tree->createSubNode($this->node_id_ru, $values);
  }
  function setUp()
  {
    $this->db =& DbFactory :: instance();
    $this->db_table_test = DbTableFactory :: create('Test1');

    $this->_cleanUp();
  }
Пример #5
0
 public function update($uid, $origin = 'app')
 {
     switch ($origin) {
         case 'osy':
             $user = $this->dba->exec_unique("SELECT o_lbl AS nam,e.p_vl AS eml,o_nam AS lgn,r.o_4 as rul,a.p_vl AS is_act,u.o_id\n                                                 FROM osy_obj u\n                                                 INNER JOIN osy_obj_rel r ON (u.o_id = r.o_3)\n                                                 LEFT JOIN osy_obj_prp e ON (u.o_id = e.o_id AND e.p_id = 'email')\n                                                 LEFT JOIN osy_obj_prp a ON (u.o_id = a.o_id AND a.p_id = 'is-active')\n                                                 WHERE u.o_id = ?", array($uid), 'NUM');
             break;
         default:
             $user = $this->dba->exec_unique("SELECT nam,eml,lgn,rul,is_act,id\n                                                 FROM osy_user\n                                                 WHERE id = ?", array($uid), 'NUM');
             break;
     }
     $stringConnection = $this->dbo->exec_query("SELECT a.p_1 as cn\n                                                  FROM osy_obj_rel r\n                                                  INNER JOIN osy_obj_rel a ON (r.o_1 = a.o_1 AND r.o_2 = a.o_2 AND a.r_typ = 'instance+application')\n                                                  WHERE r.r_typ = 'user+role'\n                                                    AND r.o_3 = ?", array($user[5]));
     foreach ($stringConnection as $rec) {
         $db = DbFactory::dbConnectionByString($rec['cn']);
         if ($db && $db->get_type() != 'oracle') {
             try {
                 $n = $db->exec_unique("SELECT count(*) FROM osy_user WHERE id = ?", array($uid));
                 if ($n > 0) {
                     $db->exec_cmd("UPDATE osy_user SET\n                                        nam = ?,\n                                        eml = ?,\n                                        lgn = ?,\n                                        rol = ?,\n                                        is_act = ?\n                                       WHERE id = ?", $user);
                 } else {
                     $db->exec_cmd("INSERT INTO osy_user \n                                        (nam,eml,lgn,rol,is_act,id) \n                                        VALUES \n                                      (?,?,?,?,?,?)", $user);
                 }
             } catch (Exception $e) {
                 switch ($e->getCode()) {
                     case '42S02':
                         //No break
                     //No break
                     case '42P01':
                         echo $e->getMessage();
                         break;
                 }
                 echo $e->getMessage();
             }
         }
     }
 }
 /**
  * @param $userId
  * @param $token
  * @return mixed
  */
 public static function getUserDataByUserIdAndToken(int $userId, string $token) : mixed
 {
     $database = DbFactory::getFactory()->getConnection();
     $query = $database->prepare("SELECT user_id, user_name, user_email, user_password_hash,\n                                          user_account_type, user_failed_logins, user_last_failed_login\n                                     FROM users\n                                     WHERE user_id = :user_id\n                                       AND user_remember_me_token = :user_remember_me_token\n                                       AND user_remember_me_token IS NOT NULL\n                                     LIMIT 1");
     $query->execute(array(':user_id' => $userId, ':user_remember_me_token' => $token));
     return $query->fetch();
 }
 /**
  * Get singleton instance of DbFactory
  * @return DbFactory
  */
 public static function getFactory() : DbFactory
 {
     if (!self::$factory) {
         self::$factory = new DbFactory();
     }
     return self::$factory;
 }
Пример #8
0
 public static function info($msg, $ecode, $etype, $uid, $schoolid, $requrl, array $param)
 {
     global $G_X;
     if ($requrl == '') {
         $requrl = $_SERVER['REQUEST_URI'];
     }
     if (!$param || count($param) < 1) {
         $param = $_REQUEST;
     }
     $Update = array();
     $Update['eventtime'] = time();
     $Update['eventtype'] = $etype;
     $Update['schoolid'] = $schoolid;
     $Update['eventdesc'] = $msg;
     $Update['message'] = print_r($param, true);
     $Update['userid'] = $uid;
     $Update['requesturl'] = $requrl;
     $Update['code'] = $ecode;
     $Update['detailcode'] = $G_X['events'][$etype][$ecode];
     $ip = real_ip();
     if ($ip == 'unknown') {
         $ip = "192.168.0.1";
     }
     $Update['ip'] = ip2long($ip);
     require_once PUBLIB_PATH . 'database/DbFactory.php';
     $db = DbFactory::Create();
     $id = $db->Insert(self::$tbname, $Update, true);
 }
Пример #9
0
 /**
  * @param string $table 表名
  * @param bool $full 是否为全表名
  * @param string $driver 连接驱动
  */
 public function __construct($table = null, $full = null, $driver = null)
 {
     $this->tableName = $this->getTable($table, $full);
     //初始化默认表
     $this->db = DbFactory::factory($driver, $this->tableName);
     //获得数据库引擎
 }
Пример #10
0
 private function getInstance()
 {
     if ($this->instance == null) {
         $this->instance = DbFactory::getInstance();
     }
     return $this->instance;
 }
Пример #11
0
 public function prepareData()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //设置用户数据
         $this->_userInfo = $data[0];
         //获取游戏数据
         $this->_oTable->setTableName('cFight');
         $this->_args['userId'] = DbFactory::getInstance('MYZL')->escape($this->_args['userId']);
         $data = $this->_oTable->getObject(array("_where" => " (user1='" . $this->_args['userId'] . "' OR user2='" . $this->_args['userId'] . "')"));
         if (empty($data)) {
             //查不到游戏数据的情况
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = " userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         } else {
             if (count($data) > 1) {
                 //有多个进行中的游戏的情况
                 $this->_retValue = EC_MULTIPLE_FIGHT;
                 $this->_retMsg = "userId:" . $this->_args['userId'];
                 interface_log(ERROR, $this->_retValue, $this->_retMsg);
                 return false;
             } else {
                 //开始游戏的操作者不是当前用户的情况
                 if ($data[0]['first'] != $this->_args['userId']) {
                     $this->_retValue = EC_ERROR_START_USR;
                     $this->_retMsg = " userId:" . $this->_args['userId'];
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
                 //操作步骤不匹配的情况
                 if ($data[0]['operation'] != START && $data[0]['operation'] != FIRST_END) {
                     $this->_retValue = EC_STEP_ERROR;
                     $this->_retMsg = " userId:" . $this->_args['userId'] . "  step:" . $data[0]['operation'];
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
             }
         }
         //设置游戏数据和游戏id
         $this->_fightInfo = $data[0];
         $this->_fightId = $data[0]['fightId'];
     } catch (Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
 function _cleanUp()
 {
     $db = DbFactory::instance();
     $db->sqlDelete('sys_action_access_template');
     $db->sqlDelete('sys_action_access_template_item');
     $db->sqlDelete('sys_action_access');
     $db->sqlDelete('sys_object_access');
 }
 public static function getLecturesByConferenceId(int $id)
 {
     $database = DbFactory::getFactory()->getConnection();
     $sql = "SELECT *\n                  FROM lectures AS l\n                 WHERE l.conference_id = :conference_id";
     $query = $database->prepare($sql);
     $query->execute(array(':conference_id' => $id));
     return $query->fetchAll(PDO::FETCH_ASSOC);
 }
  function setUp()
  {
    $this->db = DbFactory :: instance();

    $this->_cleanUp();

    $this->mapper = new OneTableObjectsMapperTestVersionMock($this);
  }
 public static function getAllConferences()
 {
     $database = DbFactory::getFactory()->getConnection();
     $sql = "SELECT c.title, c.conference_id, u.user_name, u.user_id, v.venue_name\n                  FROM conferences AS c\n                 INNER JOIN users AS u ON u.user_id = c.conference_owner_id\n                 INNER JOIN venues AS v ON v.venue_id = c.venue_id\n                 WHERE c.deleted = 0";
     $query = $database->prepare($sql);
     $query->execute();
     return $query->fetchAll(PDO::FETCH_ASSOC);
 }
  function setUp()
  {
    $this->db = DbFactory :: instance();

    $this->driver = new MaterializedPathTreeTestVersion();

    $this->_cleanUp();
  }
Пример #17
0
 public function __construct($username, $password, $error = '')
 {
     $this->username = $username;
     $this->password = $password;
     $this->error = $error;
     $this->Dbfactory = DbFactory::getinstance();
     $this->handleLogin($username, $password);
 }
 function setUp()
 {
     $this->server = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'test';
     $this->db = DbFactory::instance();
     $this->stats_referer = new StatsRefererSelfTestVersion($this);
     $this->stats_referer->__construct();
     $this->_cleanUp();
 }
 function setUp()
 {
     $this->db = DbFactory::instance();
     $this->stats_counter = new StatsCounterTestVersion($this);
     $this->stats_counter->__construct();
     $this->stats_counter->setReturnValue('_isHomeHit', false);
     $this->stats_counter->setReturnValue('_isNewAudience', false);
     $this->_cleanUp();
 }
 function setUp()
 {
     $this->db =& DbFactory::instance();
     $this->cart_handler = new SpecialDbCartHandler($this);
     $this->cart_handler->__construct(10);
     $this->user = new MockUser($this);
     $this->cart_handler->setReturnValue('_getUser', $this->user);
     $this->_cleanUp();
 }
Пример #21
0
 /**
  * This method reads the configuration options (using the getConfig method)
  * and initializes the database connections.
  *
  */
 function configure()
 {
     $connections = $this->getConfig();
     if ($connections) {
         foreach ($connections as $name => $params) {
             self::$connections[$name] = DbFactory::getConnection($params, $name);
         }
     }
 }
  function setUp()
  {
    $this->db = DbFactory :: instance();
    $this->toolkit = new MockLimbToolkit($this);
    $this->toolkit->setReturnValue('getDB', $this->db);

    $this->_cleanUp();

    $this->behaviour = new SiteObjectBehaviourTestVersion();
  }
  public function getDB()
  {
    if($this->db)
      return $this->db;

    include_once(LIMB_DIR . '/class/lib/db/DbFactory.class.php');
    $this->db = DbFactory :: instance();

    return $this->db;
  }
 function setUp()
 {
     $this->db = DbFactory::instance();
     $this->finder = new MockImageObjectsRawFinder($this);
     $this->media_manager = new MockMediaManager($this);
     $this->mapper = new ImageObjectMapperTestVersion($this);
     $this->mapper->setReturnValue('_getFinder', $this->finder);
     $this->mapper->setReturnValue('_getMediaManager', $this->media_manager);
     $this->_cleanUp();
 }
Пример #25
0
    /**
     * Visszaadja az alapertelmezett rendszer beallitasokat.
     *
     * @return array
     */
    public static function getSystemValues()
    {
        $db = DbFactory::connect();
        $query = '
			SELECT
				*
			FROM
				system
		';
        return $db->query($query)->fetchRow();
    }
Пример #26
0
function clearTestingDbTables()
{
  if(!isset($GLOBALS['testing_db_tables']))
    return;

  $db = DbFactory :: instance();

  foreach($GLOBALS['testing_db_tables'] as $table)
    $db->sqlDelete($table);

  $GLOBALS['testing_db_tables'] = array();
}
 public static function createVenueInDb(string $venueName)
 {
     $database = DbFactory::getFactory()->getConnection();
     // write new users data into database
     $sql = "INSERT INTO venues (venue_name)\n                    VALUES (:venue_name)";
     $query = $database->prepare($sql);
     $query->execute(array(':venue_name' => $venueName));
     $count = $query->rowCount();
     if ($count == 1) {
         return true;
     }
     return false;
 }
  function setUp()
  {
    parent :: setUp();

    $this->db = DbFactory :: instance();
    $this->db->sqlDelete('user');
    $this->db->sqlDelete('sys_site_object');

    $this->db->sqlInsert('sys_site_object', array('id' => 1, 'identifier' => 'vasa', 'class_id' => '1', 'current_version' => '1'));
    $this->db->sqlInsert('sys_site_object', array('id' => 2, 'identifier' => 'sasa', 'class_id' => '1', 'current_version' => '1'));
    $this->db->sqlInsert('user', array('id' => 1, 'name' => 'Vasa', 'password' => '1', 'version' => '1', 'object_id' => '1'));
    $this->db->sqlInsert('user', array('id' => 2, 'name' => 'Sasa', 'password' => '1', 'version' => '1', 'object_id' => '2'));
  }
  function setUp()
  {
    $this->user = new MockUser($this);
    $this->toolkit = new MockLimbToolkit($this);

    $this->toolkit->setReturnValue('getUser', $this->user);

    $this->db = DbFactory :: instance();
    $this->toolkit->setReturnValue('getDB', $this->db);

    Limb :: registerToolkit($this->toolkit);

    $this->driver = new SessionDbDriver();
  }
  function setUp()
  {
    $this->db = DbFactory :: instance();

    $this->_cleanUp();

    $this->_insertSysClassRecord();
    $this->_insertSysBehaviourRecord();

    $this->_insertSysSiteObjectRecords();
    $this->_insertFakeSysSiteObjectRecords();

    $this->finder = new SiteObjectsRawFinder();
  }