Welcome Guest, Not a member yet? Register   Sign In
Who can give me a answer about CI model
#1

[eluser]thesnake[/eluser]
Code:
$first = new test(1);

$second = new test(12);

print_r($first->value);

echo "<br>";

print_r($second->value);

class test
{
        var $id;
        var $value;

        function __construct($id) {
                $this->id = $id;

                $this->value = $id + 1;
        }
}

This is a simple example for PHP, I can make two object absolute.

but because of CI not support transmit a param to model, so how can i do in CI
#2

[eluser]Isern Palaus[/eluser]
Sorry, I posted something than don't reply the post. I didn't understand it at first. I don't know how to reproduce what you want in CI ;-(
#3

[eluser]thesnake[/eluser]
[quote author="Isern Palaus" date="1299075607"]Sorry, I posted something than don't reply the post. I didn't understand it at first. I don't know how to reproduce what you want in CI ;-([/quote]

post?
it's only a php simple just run it in a php file
#4

[eluser]Phil Sturgeon[/eluser]
thesnake: CodeIgniter supports the singleton pattern for models. If you would like to use something different either manually include your own libraries or use $this->load->model() to have the file included then do:

Code:
$this->load->model('test');
$first = new Test(1);
$second = new Test(12);

Remember that this is just PHP, so the intended documented ways of doing things are just suggestions.
#5

[eluser]thesnake[/eluser]
[quote author="Phil Sturgeon" date="1299082696"]thesnake: CodeIgniter supports the singleton pattern for models. If you would like to use something different either manually include your own libraries or use $this->load->model() to have the file included then do:

Code:
$this->load->model('test');
$first = new Test(1);
$second = new Test(12);

Remember that this is just PHP, so the intended documented ways of doing things are just suggestions.[/quote]

Thank you!
As you say it looks working good




Theme © iAndrew 2016 - Forum software by © MyBB