private static function canLogin($priviliagesIDs) { $privIdIn = DB::in($priviliagesIDs); $now = time(); $sql = <<<SQL SELECT fldLoginAction FROM tblSecPrivUserMap WHERE fldPrivilegeID IN ( {$privIdIn} ) AND ( fldStartDate=0 OR fldStartDate < {$now} ) AND ( fldEndDate=0 OR fldEndDate > {$now} ) AND fldLevelID IS NOT NULL AND fldLevelID <> '' AND fldLoginAction IS NOT NULL AND fldLoginAction <> '' SQL; return DB::oneValue(DB::DEF, $sql, $priviliagesIDs); }
/** * @param $row * @return bool|mixed */ public function insert($row, $insertMethod = 'INSERT') { $row = $this->objToRel($row); // This allows for dummy columns to be part of the object without the // DAO automatically accessing them in the queries. if ($this->ignoreCols != null) { foreach ($this->ignoreCols as $ignoreCol) { unset($row[$ignoreCol]); } } if (Cfg::get('jb_db', false)) { $pKey = DBMaintenance::dbNextNumber($this->db, $this->tableName); $row[$this->primaryKey] = $pKey; } $keys = array_keys($row); $values = array_values($row); $sql = $insertMethod . ' INTO ' . $this->tableName . ' (' . join(',', $keys) . ') VALUES (' . DB::in($values) . ')'; if (DB::exec($this->db, $sql, $values) != 1) { return false; } if (!Cfg::get('jb_db', false)) { $pKey = DB::lastInsertId($this->db); } return $pKey; }
protected function insertRows() { $rowsToInsert = (int) Request::get('rows'); $insertedCnt = 0; for ($i = 0; $i < $rowsToInsert; $i++) { $params = array_merge($this->insDefaults, $this->where); $paramValues = null; if (Cfg::get('jb_db', false)) { $params[$this->primaryKey] = DBMaintenance::dbNextNumber($this->db, $this->tableName); } $sql = 'INSERT INTO ' . $this->tableName; if (count($params) > 0) { $sql .= ' (' . join(',', array_keys($params)) . ') ' . 'VALUES (' . DB::in(array_values($params), $paramValues) . ')'; } $insertedCnt += $this->exec($sql, $paramValues); } if ($insertedCnt > 0) { $this->paginator->setRows($this->getRowCount()); } return 'Inserted ' . $insertedCnt . ' row' . StringUtil::plural($insertedCnt) . Tag::br(); }