0

ユーザーテーブルに登録したユーザーをリストしています。しかし、名前の列に「SuperAdmin」という名前を隠したいです。

私のクエリはこのようなものです

$sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.job, u.signature, u.office_phone, u.office_fax, u.user_mobile,";
        $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,";
        $sql.= " u.pass, u.pass_crypted, u.pass_temp,";
        $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,";
        $sql.= " u.statut, u.lang, u.entity,";
        $sql.= " u.datec as datec,";
        $sql.= " u.tms as datem,";
        $sql.= " u.datelastlogin as datel,";
        $sql.= " u.datepreviouslogin as datep,";
        $sql.= " u.photo as photo,";
        $sql.= " u.openid as openid,";
        $sql.= " u.ref_int, u.ref_ext";
        $sql.= " FROM ".MAIN_DB_PREFIX."user as u";


if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
        {
            $sql.= " WHERE u.entity IS NOT NULL";
        }
        else
        {
            $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
        }

        if ($sid)    // permet une recherche du user par son SID ActiveDirectory ou Samba
        {
            $sql.= " AND (u.ldap_sid = '".$sid."' OR u.login = '".$this->db->escape($login)."') LIMIT 1";
        }
        else if ($login)
        {
            $sql.= " AND u.login = '".$this->db->escape($login)."'";
        }
        else
        {
            $sql.= " AND u.rowid = ".$id;
        }

        dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
        $result = $this->db->query($sql);
        if ($result)
        {
            $obj = $this->db->fetch_object($result);
            if ($obj)
            {
                $this->id           = $obj->rowid;
                $this->ref          = $obj->rowid;

                $this->ref_int      = $obj->ref_int;
                $this->ref_ext      = $obj->ref_ext;

                $this->ldap_sid     = $obj->ldap_sid;
                $this->nom          = $obj->name;       // TODO deprecated
                $this->lastname     = $obj->name;
                $this->prenom       = $obj->firstname;  // TODO deprecated
                $this->firstname    = $obj->firstname;

                $this->login        = $obj->login;
                $this->pass_indatabase = $obj->pass;
                $this->pass_indatabase_crypted = $obj->pass_crypted;
                $this->pass         = $obj->pass;
                $this->pass_temp    = $obj->pass_temp;
                $this->office_phone = $obj->office_phone;
                $this->office_fax   = $obj->office_fax;
                $this->user_mobile  = $obj->user_mobile;
                $this->email        = $obj->email;
                $this->job          = $obj->job;
                $this->signature    = $obj->signature;
                $this->admin        = $obj->admin;
                $this->note         = $obj->note;
                $this->statut       = $obj->statut;
                $this->photo        = $obj->photo;
                $this->openid       = $obj->openid;
                $this->lang         = $obj->lang;
                $this->entity       = $obj->entity;

                $this->datec                = $this->db->jdate($obj->datec);
                $this->datem                = $this->db->jdate($obj->datem);
                $this->datelastlogin        = $this->db->jdate($obj->datel);
                $this->datepreviouslogin    = $this->db->jdate($obj->datep);

                $this->webcal_login         = $obj->webcal_login;
                $this->phenix_login         = $obj->phenix_login;
                $this->phenix_pass_crypted  = $obj->phenix_pass;
                $this->societe_id           = $obj->fk_societe;
                $this->contact_id           = $obj->fk_socpeople;
                $this->fk_member            = $obj->fk_member;

                if (! $this->lang) $this->lang='fr_FR';

                $this->db->free($result);

UNION メソッドでそれを行うことは可能ですか、誰かが私を助けてくれます。Where Distinct を追加しようとしましたが、うまくいきませんでした。SuperAdmin という名前を非表示にしたいだけです

4

3 に答える 3

2

これを FROM 行の後に追加します

$sql.= " WHERE u.name != 'SuperAdmin'";
于 2013-05-02T12:15:33.917 に答える
0

このように、クエリの最後に WHERE 条件を追加できます

$sql .= " WHERE u.name NOT LIKE 'SuperAdmin' ";

于 2013-05-02T12:22:11.953 に答える