Esempio n. 1
0
 /**
  * generate sql string
  *
  * @return string
  * @throws base_database_Exception
  */
 public function toString()
 {
     $result = 'DELETE FROM ';
     $result .= $this->table->getName();
     if (empty($this->where)) {
         throw new base_database_Exception(TMS(base_database_Exception::NO_WHERE_GIVEN));
     }
     $result .= ' WHERE ';
     $result .= $this->where->toString();
     return $result;
 }
Esempio n. 2
0
 /**
  * generate sql string
  *
  * @return string
  */
 public function toString()
 {
     if (empty($this->columnValues)) {
         return '';
     }
     $result = 'INSERT INTO ';
     $result .= $this->table->getName();
     $result .= ' (' . implode(',', array_keys($this->columnValues)) . ') ';
     $result .= 'VALUES (' . implode(',', array_values($this->columnValues)) . ')';
     return $result;
 }
Esempio n. 3
0
 /**
  * generate sql string
  *
  * @return string
  */
 public function toString()
 {
     $result = 'UPDATE ';
     $result .= $this->table->getName();
     $result .= ' SET ';
     if (empty($this->columnValues) === false) {
         $result .= implode(', ', $this->columnValues);
     }
     if (empty($this->where) === false) {
         $result .= ' WHERE ';
         $result .= $this->where->toString();
     }
     return $result;
 }
Esempio n. 4
0
File: CSV.php Progetto: kafruhs/fws
 /**
  * @param $result
  * @return base_database_statement_Insert|base_database_statement_Update
  * @throws base_database_Exception
  */
 protected function getStatementForImport($result)
 {
     if (empty($result)) {
         $statement = new base_database_statement_Insert();
         return $statement;
     } else {
         $statement = new base_database_statement_Update();
         $colPK = $this->table->getColumn('PK');
         $statement->setWhere(DB::where($colPK, DB::intTerm($result)));
         return $statement;
     }
 }
Esempio n. 5
0
    public function count($historic = false)
    {
        $columns = array($this->table->getColumn('LK'));

        if ($historic == false) {
            if (empty($this->where)) {
                $this->where = DB::where($this->table->getColumn('histtop'), DB::term('Y'));
            } else {
                $this->where->addAnd($this->table->getColumn('histtop'), DB::term('Y'));
            }
        }

        if (empty($this->order)) {
            $this->order = new base_database_Order($this->table->getColumn('LK'), base_database_Order::ASC);
        }

        $select = $this->_createSelectStatement($columns);
        $result = $select->fetchDatabase();

        return count($result);
    }
Esempio n. 6
0
 /**
  * set existing actual revision of the object to self::HISTORIC
  *
  * @param $table
  * @param $historicValue
  * @return base_database_statement_Update
  * @throws base_database_Exception
  */
 private function _setHistoricData(base_database_Table $table, $historicValue)
 {
     $statement = new base_database_statement_Update();
     $where = DB::where($table->getColumn('histtop'), DB::term(self::ACTUAL));
     $where->addAnd($table->getColumn('LK'), DB::intTerm((int) $this['LK']));
     $statement->setTable($table);
     $statement->setWhere($where);
     $statement->setColumnValue($table->getColumn('histtop'), DB::term($historicValue));
     $statement->insertDatabase();
 }
Esempio n. 7
0
File: User.php Progetto: kafruhs/fws
    private static function _updateLoginTries(base_database_Table $table, User $user)
    {
        $loginTries = $user['loginTries'];
        $where = DB::where($table->getColumn('userid'), DB::term($user['userid']));
        if ($loginTries < self::LOGIN_MAX_TRIES) {
            $loginTries++;
            self::_updateUserLoginData($table, $where, array('loginTries' => DB::term($loginTries)));
            return self::LOGIN_FAILURE;
        }
        if ($loginTries >= self::LOGIN_MAX_TRIES) {
            self::_updateUserLoginData($table, $where, array('disabled' => DB::term(self::USER_DISABLED)));
            return self::LOGIN_USER_DISABLED;
        }
        return self::LOGIN_FAILURE;

    }