Welcome Guest, Not a member yet? Register   Sign In
Constructors and Parametes
#6

[eluser]eggshape[/eluser]
Well how are $firstname and $lastname assigned? If you're assigning from a form, you don't need to pass the parameters:

Code:
function __construct()
   {
     $this->firstname = $this->input->post('firstname');
     $this->lastname = $this->input->post('lastname');
   }

However, I would advise against this because you have not validated the form fields. Alternatively, you can instantiate the model (load it), run validation, and then call your method createNew(), like how MaadMac suggested. Note, you can do all this in the constructor if you wish.


Messages In This Thread
Constructors and Parametes - by El Forum - 12-11-2007, 10:39 PM
Constructors and Parametes - by El Forum - 12-11-2007, 10:50 PM
Constructors and Parametes - by El Forum - 12-11-2007, 11:16 PM
Constructors and Parametes - by El Forum - 12-11-2007, 11:57 PM
Constructors and Parametes - by El Forum - 12-12-2007, 07:22 AM
Constructors and Parametes - by El Forum - 12-12-2007, 11:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB