Welcome Guest, Not a member yet? Register   Sign In
nested problem
#1

[eluser]Aditzu[/eluser]
Hi. I'm trying to make an object like this:
Code:
class Order{
    public function orderId();
    public function DateTime CreationDate();
    public function  DateTime ValidationDate();
    public function DateTime ProcessedDate();
    public function OrderStatus OrdStatus();
    public function int PickUpSiteId();
    public function string PickUpSiteName();
    public function DateTime PickUpDateFrom();
    public function DateTime PickUpDateUntil();
    public function int NoAwb();
    public function int NoParcel();
    public function int NoEnvelop();
    public function int IdOrasExp();
    public function string AdresaExp();
    public function int GreutateTotala();
    public function string Email();
    }
    $order=new Order;
    $order->CreationDate=new CreationDate();
    $order->ValidationDate=new ValidationDate();
    $order->ProcessedDate=new ProcessedDate();
    $order->OrdStatus=new OrdStatus();
    $order->PickUpSiteId=new PickUpSiteId();
    $order->PickUpSiteName=new PickUpSiteName();
    $order->PickUpDateFrom=new PickUpDateFrom();
    $order->PickUpDateUntil=new PickUpDateUntil();
    $order->NoAwb=new NoAwb();
    $order->NoParcel=new NoParcel();
    $order->NoEnvelop=new NoEnvelop();
    $order->IdOrasExp=new IdOrasExp();
    $order->AdresaExp=new AdresaExp();
    $order->GreutateTotala=new GreutateTotala();
    $order->Email=new Email();

and I get an error like this :

Class declarations may not be nested in /var/www/clients/client1/web21/web/application/controllers/index_urgent.php on line 180

..where line 180 is the first line "class Order{". What should be the problem? Thanks!
#2

[eluser]PhilTem[/eluser]
I'm not 100% sure to get what you're doing, but I see several things that I've never seen anywhere else before. Try changing your code to

Code:
class Order {
  public $CreationDate;
  public $ValidationDate;
}

$order = new Order();
$order->CreationDate = new CreationDate();

and so on an so forth for all other methods you want to assign.

Then you should not get these problems (I hope).

Plus: IMHO return value types is not supported in PHP like it is in C/C++ or Java. So things like

Code:
public function int NoAwb() {}

will produce nothing else but errors Wink
#3

[eluser]Aditzu[/eluser]
Ok i understand. But I've got same error. Now my code looks something like this:
Code:
class Order{
    public orderId();
    public CreationDate();
    public ValidationDate();
    public  ProcessedDate();
    public OrdStatus();
    public PickUpSiteId();
    public  PickUpSiteName();
    public   PickUpDateFrom();
    public   PickUpDateUntil();
    public  NoAwb();
    public NoParcel();
    public NoEnvelop();
    public   IdOrasExp();
    public   AdresaExp();
    public  GreutateTotala();
    public  Email();
    }
  
    $order=new Order;
    $order->CreationDate = new CreationDate();
    $order->ValidationDate=new ValidationDate();
    $order->ProcessedDate=new ProcessedDate();
    $order->OrdStatus=new OrdStatus();
    $order->PickUpSiteId=new PickUpSiteId();
    $order->PickUpSiteName=new PickUpSiteName();
    $order->PickUpDateFrom=new PickUpDateFrom();
    $order->PickUpDateUntil=new PickUpDateUntil();
    $order->NoAwb=new NoAwb();
    $order->NoParcel=new NoParcel();
    $order->NoEnvelop=new NoEnvelop();
    $order->IdOrasExp=new IdOrasExp();
    $order->AdresaExp=new AdresaExp();
    $order->GreutateTotala=new GreutateTotala();
    $order->Email=new Email();

and my sweet error is " Class declarations may not be nested in /var/www/clients/client1/web21/web/application/controllers/index_urgent.php on line 181" where line 181 is the first line from here. Any ideas?Thanks also for reply PhilTem.
#4

[eluser]PhilTem[/eluser]
You still have brackets in the declaration of attributes. Remove all () after orderId, CreationDate, ValidationDate, ... then it should work
#5

[eluser]Aditzu[/eluser]
[quote author="PhilTem" date="1352214795"]You still have brackets in the declaration of attributes. Remove all () after orderId, CreationDate, ValidationDate, ... then it should work[/quote]

And still it doesn't. I have same error


Code:
class   Order{
    public  orderId;
    public  CreationDate;
    public  ValidationDate;
    public  ProcessedDate;
    public  OrdStatus;
    public  PickUpSiteId;
    public  PickUpSiteName;
    public  PickUpDateFrom;
    public  PickUpDateUntil;
    public  NoAwb;
    public  NoParcel;
    public  NoEnvelop;
    public  IdOrasExp;
    public  AdresaExp;
    public  GreutateTotala;
    public  Email;
    }
  
    $order=new Order;
    $order->CreationDate = new CreationDate();
    $order->ValidationDate=new ValidationDate();
    $order->ProcessedDate=new ProcessedDate();
    $order->OrdStatus=new OrdStatus();
    $order->PickUpSiteId=new PickUpSiteId();
    $order->PickUpSiteName=new PickUpSiteName();
    $order->PickUpDateFrom=new PickUpDateFrom();
    $order->PickUpDateUntil=new PickUpDateUntil();
    $order->NoAwb=new NoAwb();
    $order->NoParcel=new NoParcel();
    $order->NoEnvelop=new NoEnvelop();
    $order->IdOrasExp=new IdOrasExp();
    $order->AdresaExp=new AdresaExp();
    $order->GreutateTotala=new GreutateTotala();
    $order->Email=new Email();
#6

[eluser]Ewout[/eluser]
If you are trying to make an object with this list of properties then make them variables...

Code:
class Order {
    public  $orderId;
    public  $CreationDate;
    public  $ValidationDate;
    public  $ProcessedDate;
    public  $OrdStatus;
    public  $PickUpSiteId;
    public  $PickUpSiteName;
    public  $PickUpDateFrom;
    public  $PickUpDateUntil;
    public  $NoAwb;
    public  $NoParcel;
    public  $NoEnvelop;
    public  $IdOrasExp;
    public  $AdresaExp;
    public  $GreutateTotala;
    public  $Email;
}
  
$order=new Order;
$order->CreationDate = new CreationDate();
$order->ValidationDate=new ValidationDate();
$order->ProcessedDate=new ProcessedDate();
$order->OrdStatus=new OrdStatus();
$order->PickUpSiteId=new PickUpSiteId();
$order->PickUpSiteName=new PickUpSiteName();
$order->PickUpDateFrom=new PickUpDateFrom();
$order->PickUpDateUntil=new PickUpDateUntil();
$order->NoAwb=new NoAwb();
$order->NoParcel=new NoParcel();
$order->NoEnvelop=new NoEnvelop();
$order->IdOrasExp=new IdOrasExp();
$order->AdresaExp=new AdresaExp();
$order->GreutateTotala=new GreutateTotala();
$order->Email=new Email();
#7

[eluser]PhilTem[/eluser]
[quote author="Ewout" date="1352219626"]If you are trying to make an object with this list of properties then make them variables...[/quote]

That one has to work! Otherwise my knowledge is useless Tongue
#8

[eluser]Aditzu[/eluser]
mates I'm sorry but I have same old same error " Class declarations may not be nested in.."

and my code looks something like this:
Code:
class   Order{
    public  $orderId;
    public  $CreationDate;
    public  $ValidationDate;
    public  $ProcessedDate;
    public  $OrdStatus;
    public  $PickUpSiteId;
    public  $PickUpSiteName;
    public  $PickUpDateFrom;
    public  $PickUpDateUntil;
    public  $NoAwb;
    public  $NoParcel;
    public  $NoEnvelop;
    public  $IdOrasExp;
    public  $AdresaExp;
    public  $GreutateTotala;
    public  $Email;
    }
  
    $order=new Order;
    $order->CreationDate = new CreationDate();
    $order->ValidationDate=new ValidationDate();
    $order->ProcessedDate=new ProcessedDate();
    $order->OrdStatus=new OrdStatus();
    $order->PickUpSiteId=new PickUpSiteId();
    $order->PickUpSiteName=new PickUpSiteName();
    $order->PickUpDateFrom=new PickUpDateFrom();
    $order->PickUpDateUntil=new PickUpDateUntil();
    $order->NoAwb=new NoAwb();
    $order->NoParcel=new NoParcel();
    $order->NoEnvelop=new NoEnvelop();
    $order->IdOrasExp=new IdOrasExp();
    $order->AdresaExp=new AdresaExp();
    $order->GreutateTotala=new GreutateTotala();
    $order->Email=new Email();
#9

[eluser]Aditzu[/eluser]
now i'm good. Because i'm new in codeigniter I didn't know that a class needs to be declared in a library. So that was the problem.

Now I put in a library:
Code:
class urgent
{
  
  
  public function orderId(){}
  public function CreationDate(){}
  public function ValidationDate(){}
  public function ProcessedDate(){}
  public function OrdStatus(){}
  public function PickUpSiteId(){}
  public function PickUpSiteName(){}
  public function PickUpDateFrom(){}
  public function PickUpDateUntil(){}
  public function NoAwb(){}
  public function NoParcel(){}
  public function NoEnvelop(){}
  public function IdOrasExp(){}  
  public function AdresaExp(){}  
  public function GreutateTotala(){}  
  public function Email(){}

}

and in controller:
Code:
$this->load->library('urgent');
$order=new urgent();

Thanks a lot for your support.




Theme © iAndrew 2016 - Forum software by © MyBB