public function find($arg = null, $operator = '=', $fields = array('*'))
    {
        if ($fields[0] == '*') {
            $this->select();
        } else {
            $select_args = '';
            foreach ($fields as $key => $field) {
                if (is_array($field) && is_string($key)) {
                    foreach ($field as $part) {
                        $select_args .= $key . '.' . $part . ', ';
                    }
                } else {
                    $select_args .= $this->oosql_table . '.' . $field . ', ';
                }
            }

            $this->select(rtrim($select_args, ','));
        }
        if (!is_array($arg)) {
            $obj = $this->getEntityObject();
            $pri = $obj->getPrimary();
            if (null !== $arg) {
                $arg = array($pri[0] => $arg);
            }
        }
        $i = 0;
        $flag = '';
        if (is_array($arg)) {
            foreach ($arg as $col => $val) {
                if ($i > 0) {
                    $flag = 'and';
                }
                $this->where("$this->oosql_table.$col $operator ?", $val, $flag);
                $i++;
            }
        }



        return $this;
    }
public function find($arg = null, $operator = '=', $fields = array('*'))
    {
        if ($fields[0] == '*') {
            $this->select();
        } else {
            $select_args = '';
            foreach ($fields as $key => $field) {
                if (is_array($field) && is_string($key)) {
                    foreach ($field as $part) {
                        $select_args .= $key . '.' . $part . ', ';
                    }
                } else {
                    $select_args .= $this->oosql_table . '.' . $field . ', ';
                }
            }

            $this->select(rtrim($select_args, ','));
        }
        if (!is_array($arg)) {
            $obj = $this->getEntityObject();
            $pri = $obj->getPrimary();
            if (null !== $arg) {
                $arg = array($pri[0] => $arg);
            }
        }
        $i = 0;
        $flag = '';
        if (is_array($arg)) {
            foreach ($arg as $col => $val) {
                if ($i > 0) {
                    $flag = 'and';
                }
                $this->where("$this->oosql_table.$col $operator ?", $val, $flag);
                $i++;
            }
        }



        return $this;
    }
public function find ( $ arg = null , $ operator = '=' , $ fields = array ( '*' ) ) { if ( $ fields [ 0 ] == '*' ) { $ this -> select ( ) ; } else { $ select_args = '' ; foreach ( $ fields as $ key => $ field ) { if ( is_array ( $ field ) && is_string ( $ key ) ) { foreach ( $ field as $ part ) { $ select_args .= $ key . '.' . $ part . ', ' ; } } else { $ select_args .= $ this -> oosql_table . '.' . $ field . ', ' ; } } $ this -> select ( rtrim ( $ select_args , ',' ) ) ; } if ( ! is_array ( $ arg ) ) { $ obj = $ this -> getEntityObject ( ) ; $ pri = $ obj -> getPrimary ( ) ; if ( null !== $ arg ) { $ arg = array ( $ pri [ 0 ] => $ arg ) ; } } $ i = 0 ; $ flag = '' ; if ( is_array ( $ arg ) ) { foreach ( $ arg as $ col => $ val ) { if ( $ i > 0 ) { $ flag = 'and' ; } $ this -> where ( "$this->oosql_table.$col $operator ?" , $ val , $ flag ) ; $ i ++ ; } } return $ this ; }
Find records with a filtering condition
@param string $arg
@param string $operator
@param array $fields
@return \Phiber\oosql\oosql
Find records with a filtering condition