Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Упрощение loadObject #1036

Open
xor2016 opened this issue May 28, 2022 · 0 comments
Open

Упрощение loadObject #1036

xor2016 opened this issue May 28, 2022 · 0 comments

Comments

@xor2016
Copy link
Contributor

xor2016 commented May 28, 2022

function loadObject($id)

Основываясь на предположении, что объект ДОЛЖЕН принадлежать к какому-нибудь классу избавляемся от лишнего запроса

 
function loadObject($id)
    {
        $rec = SQLSelectOne("SELECT  objects.*,classes.TITLE CL_TITLE  FROM objects join classes ON objects.CLASS_ID = classes.ID WHERE objects.ID=" . (int)$id);
        if (IsSet($rec['ID'])) {
            $this->id = $rec['ID'];
            $this->object_title = $rec['TITLE'];
            $this->class_id = $rec['CLASS_ID'];
            $this->class_title = $rec['CL_TITLE'];
            $this->description = $rec['DESCRIPTION'];
            $this->location_id = $rec['LOCATION_ID'];
            if (preg_match('/^sdevice(.+?)/', $rec['SYSTEM'], $m)) {
                $this->device_id = $m[1];
            }
        } else {
            return false;
        }
    }


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant