• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post sheet

#1
Hello guys,
I have an webapp which the user insert a specific sheet. Those sheets are predefined by the admin. So... some sheets have 15 lines, other ones have 50.
On submit, the user can to choose to SAVE or to SEND or to EXPORT or to PRINT the sheet.
But, if the user choice be SEND or EXPORT or PRINT, the sheet need to save itself first.

I am using something like that:

PHP Code:
Class Sheet {

 
   public function save() {
 
       // form validation run here
 
       // save in DB
 
   }

 
   public function send() {
 
       // form validation run here
 
       // save in DB
 
       // write the output file
 
   }




Of course I have a redundance in validating and saving the data into DB.

I tried to do something like that

PHP Code:
   public function send() {
 
       $this->save();
 
       //code to write
 
   

and also tried changing save to a static method

PHP Code:
   public function send() {
 
       self::save()
 
       // code to write
 
   


None work.
Some suggestion?
Reply

#2
If your using a class library then you need to access external methods using the CI Super Object.

Code:
class yourClass
{
    private $_ci;

    public function __construct()
    {
        parent:: __construct();

        $this->_ci = get_instance();
    }
}

// access db and models using $this->_ci->db->get() etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
It it is your own class, you have to load it first. Did you do that?

Reply

#4
(12-13-2014, 06:59 AM)InsiteFX Wrote: If your using a class library then you need to access external methods using the CI Super Object.


Code:
class yourClass
{
   private $_ci;

   public function __construct()
   {
       parent:: __construct();

       $this->_ci = get_instance();
   }
}

// access db and models using $this->_ci->db->get() etc;

This code will trigger a fatal error. There's no 'parent' to call when you don't extend anything.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.