Jump to content
tijojoel

Redeclaring error

Recommended Posts

Hi,

 

I am just developing a crud in prestashop. I want to create two tables on install and the problem I am facing is fatal error due to redeclare of variable. 

 

<?php
require_once 'CustomObjectModel.php';
 
class HierarchyModel extends HierarchyCustomObjectModel
{
  //organization levels  
  public static $definition = [
  'table'     => 'organization',
  'primary'   => 'id_organization',
  'multilang' => true,        
  'fields'    => [
  'id_organization'           => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
  'org_level'         => ['type' => self::TYPE_INT, 'db_type' => 'int(11)', 'lang' => true],
  'parent_level'         => ['type' => self::TYPE_INT, 'db_type' => 'int(11)', 'lang' => true],
  'org_name'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],
  'org_address1'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],   
  'org_address2'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],     
  'org_state'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],
  'org_city'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],  
  'org_zipcode'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)', 'lang' => true],        
 
  'date_add'      => [
  'type'     => self::TYPE_DATE,
  'validate' => 'isDate',
  'db_type'  => 'datetime',
  ],
  'date_upd'      => [
  'type'     => self::TYPE_DATE,
  'validate' => 'isDate',
  'db_type'  => 'datetime',
  ],
  ],
  ];  
  public $id_organization;
  public $org_name;
  public $org_level;
  public $org_address1;
  public $org_address2;
  public $org_state;    
  public $org_city;    
  public $org_zipcode;    
  public $parent_level;  
  public $date_add;
  public $date_upd;
 
  //admin levels
  public static $definition1 = [
  'table'     => 'admin_levels',
  'primary'   => 'id_admin',
  'fields'    => [
  'id_admin'           => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
  'admin_level'         => ['type' => self::TYPE_INT, 'db_type' => 'int(11)'],  
  'admin_level_name'         => ['type' => self::TYPE_STRING, 'db_type' => 'varchar(255)'], 
  ],
  ];
 
  public $id_admin;
  public $admin_level;
  public $admin_level_name;  
}
 
Look on $definition and $definition1. I need to give $definition then only the code works if I am giving both $definition- cause fatal error, if for one i had given other one will not work. Please help me

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More