Code Monkey home page Code Monkey logo

Comments (1)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
The followings contain some bug fixed for above two methods: get_value() and 
set_value()

    public function get_value()
    {
        unset($value);

        foreach ($this->names as $index => $_name)
        {
            if (is_array($this->values[$index]))
            {
                $value->$_name = array();
                foreach ($this->values[$index] as $_value)
                {
                    array_push($value->$_name, $_value->get_value());
                }
            }
            else
            {
                if (isset($this->values[$index]) AND ! empty($this->values[$index]))
                {
                    $value->$_name = $this->values[$index]->get_value();
                }
            }
        }

        return $value;
    }


    public function set_value($value)
    {
        foreach ($this->names as $index => $_name)
        {
            if ( ! isset($value->$_name))
                continue;

            if (is_array($value->$_name) AND is_array($this->values[$index]))
            {
                $this->values[$index] = array();
                foreach ($value->$_name as $_value)
                {
                    $class_object = new $this->fields[$index]();
                    $class_object->set_value($_value);
                    $this->values[$index][] = $class_object;
                }
            }
            else
            {
                if ( ! isset($this->values[$index]) OR empty($this->values[$index]))
                {
                    $this->values[$index] = new $this->fields[$index]();
                }
                $this->values[$index]->set_value($value->$_name);
            }
        }
    }

Original comment by [email protected] on 7 Jul 2009 at 12:01

from pb4php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.