Subversion Repositories oidplus

Rev

Rev 1148 | Rev 1199 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1148 Rev 1156
Line 45... Line 45...
45
         * @return bool|null
45
         * @return bool|null
46
         * @throws OIDplusException
46
         * @throws OIDplusException
47
         */
47
         */
48
        public static function alreadyHasFreeOid(string $email, bool $getId = false)/*: ?bool*/ {
48
        public static function alreadyHasFreeOid(string $email, bool $getId = false)/*: ?bool*/ {
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ?", array($email, self::getFreeRootOid(true).'.%'));
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ?", array($email, self::getFreeRootOid(true).'.%'));
50
                $res = new OIDplusNaturalSortedQueryResult($res, 'id');
50
                $res->naturalSortByField('id');
51
                if ($row = $res->fetch_array()) {
51
                if ($row = $res->fetch_array()) {
52
                        return $getId ? $row['id'] : true;
52
                        return $getId ? $row['id'] : true;
53
                }
53
                }
54
                return $getId ? null : false;
54
                return $getId ? null : false;
55
        }
55
        }
Line 369... Line 369...
369
         * @return int
369
         * @return int
370
         * @throws OIDplusException
370
         * @throws OIDplusException
371
         */
371
         */
372
        protected static function freeoid_max_id(): int {
372
        protected static function freeoid_max_id(): int {
373
                $res = OIDplus::db()->query("select id from ###objects where id like ?", array(self::getFreeRootOid(true).'.%'));
373
                $res = OIDplus::db()->query("select id from ###objects where id like ?", array(self::getFreeRootOid(true).'.%'));
374
                $res = new OIDplusNaturalSortedQueryResult($res, 'id');
374
                $res->naturalSortByField('id');
375
                $highest_id = 0;
375
                $highest_id = 0;
376
                while ($row = $res->fetch_array()) {
376
                while ($row = $res->fetch_array()) {
377
                        $arc = substr_count(self::getFreeRootOid(false), '.')+1;
377
                        $arc = substr_count(self::getFreeRootOid(false), '.')+1;
378
                        $highest_id = explode('.',$row['id'])[$arc];
378
                        $highest_id = explode('.',$row['id'])[$arc];
379
                }
379
                }