noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | Protected Attributes
Profile_Menu_sql Class Reference

Manage the table public.profile_menu. More...

Public Member Functions

 __construct (&$p_cn, $p_id=-1)
 delete ()
 get_info ()
 get_object ($p_ret, $idx)
 get_seek return the next object, the return of the query must have all the column of the object
 get_parameter ($p_string)
 insert ()
 load ()
 load a object
 save ()
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition
 set_parameter ($p_string, $p_value)
 update ()
 verify ()

Static Public Member Functions

static test_me ()
 Unit test for the class.

Protected Attributes

 $variable

Detailed Description

Manage the table public.profile_menu.

Definition at line 37 of file class_profile_menu_sql.php.


Constructor & Destructor Documentation

Profile_Menu_sql::__construct ( &$  p_cn,
p_id = -1 
)

Definition at line 48 of file class_profile_menu_sql.php.

References $value, cn, and load().

                                           {
        $this->cn=$p_cn;
        $this->pm_id=$p_id;
        
        if ( $p_id == -1 ) {
        /* Initialize an empty object */
            foreach ($this->variable as $key=>$value) $this->$value=null;
            $this->pm_id=$p_id;
        } else {
         /* load it */

         $this->load();
      }
  }

Member Function Documentation

Definition at line 245 of file class_profile_menu_sql.php.

References $res, $sql, and cn.

                           {
    $sql="delete from public.profile_menu where pm_id=$1"; 
    $res=$this->cn->exec_sql($sql,array($this->pm_id));
  }

Definition at line 78 of file class_profile_menu_sql.php.

{    return var_export($this,true);  }
Profile_Menu_sql::get_object ( p_ret,
idx 
)

get_seek return the next object, the return of the query must have all the column of the object

Parameters:
$p_retis the return value of an exec_sql
$idxis the index
See also:
seek
Returns:
object

Definition at line 127 of file class_profile_menu_sql.php.

References $array, $idx, $value, cn, and Database\fetch_array().

    {
     // map each row in a object
     $oobj=new Profile_Menu_sql ($this->cn);
     $array=Database::fetch_array($p_ret,$idx);
     foreach ($array as $idx=>$value) { $oobj->$idx=$value; }
     return $oobj;
   }

Definition at line 62 of file class_profile_menu_sql.php.

References $idx.

                                           {
    if ( array_key_exists($p_string,$this->variable) ) {
      $idx=$this->variable[$p_string];
      return $this->$idx;
    }
    else 
      throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
  }

Definition at line 135 of file class_profile_menu_sql.php.

References $sql, cn, and verify().

Referenced by save().

                           {
    if ( $this->verify() != 0 ) return;
      if( $this->pm_id==-1 ){
    /*  please adapt */
    $sql="insert into public.profile_menu(me_code
,me_code_dep
,p_id
,p_order
,p_type_display
,pm_default
) values ($1
,$2
,$3
,$4
,$5
,$6
) returning pm_id";
    
    $this->pm_id=$this->cn->get_value(
                 $sql,
                 array( $this->me_code
,$this->me_code_dep
,$this->p_id
,$this->p_order
,$this->p_type_display
,$this->pm_default
)
                 );
          } else {
              $sql="insert into public.profile_menu(me_code
,me_code_dep
,p_id
,p_order
,p_type_display
,pm_default
,pm_id) values ($1
,$2
,$3
,$4
,$5
,$6
,$7
) returning pm_id";
    
    $this->pm_id=$this->cn->get_value(
                 $sql,
                 array( $this->me_code
,$this->me_code_dep
,$this->p_id
,$this->p_order
,$this->p_type_display
,$this->pm_default
,$this->pm_id)
                 );

          }
   
  }

load a object

Returns:
0 on success -1 the object is not found

Definition at line 220 of file class_profile_menu_sql.php.

References $idx, $res, $sql, $value, and cn.

Referenced by __construct().

                         {

   $sql="select me_code
,me_code_dep
,p_id
,p_order
,p_type_display
,pm_default
 from public.profile_menu where pm_id=$1"; 
    /* please adapt */
    $res=$this->cn->get_array(
                 $sql,
                 array($this->pm_id)
                 );
                 
    if ( count($res) == 0 ) {
          /* Initialize an empty object */
          foreach ($this->variable as $key=>$value) $this->$key='';

          return -1;
          }
    foreach ($res[0] as $idx=>$value) { $this->$idx=$value; }
    return 0;
  }

Definition at line 97 of file class_profile_menu_sql.php.

References insert(), and update().

                         {
  /* please adapt */
    if (  $this->pm_id == -1 ) 
      $this->insert();
    else
      $this->update();
  }
Profile_Menu_sql::seek ( cond = '',
p_array = null 
)

retrieve array of object thanks a condition

Parameters:
$condcondition (where clause) (optional by default all the rows are fetched) you can use this parameter for the order or subselect
$p_arrayarray for the SQL stmt
See also:
Database::exec_sql get_object Database::num_row
Returns:
the return value of exec_sql

Definition at line 112 of file class_profile_menu_sql.php.

References $p_array, $ret, $sql, and cn.

   {
     $sql="select * from public.profile_menu  $cond";
     $aobj=array();
     $ret= $this->cn->exec_sql($sql,$p_array);
     return $ret;
   }
Profile_Menu_sql::set_parameter ( p_string,
p_value 
)

Definition at line 70 of file class_profile_menu_sql.php.

References $idx.

                                                    {
    if ( array_key_exists($p_string,$this->variable) ) {
      $idx=$this->variable[$p_string];
      $this->$idx=$p_value;
    }
    else 
      throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
  }
static Profile_Menu_sql::test_me ( ) [static]

Unit test for the class.

Definition at line 252 of file class_profile_menu_sql.php.

References $cn, $obj, echo, and h2info().

                            {
      $cn=new Database(25);
$cn->start();
    echo h2info('Test object vide');
    $obj=new Profile_Menu_sql($cn);
    var_dump($obj);

    echo h2info('Test object NON vide');
    $obj->set_parameter('j_id',3);
    $obj->load();
    var_dump($obj);

    echo h2info('Update');
    $obj->set_parameter('j_qcode','NOUVEAU CODE');
    $obj->save();
    $obj->load();
    var_dump($obj);

    echo h2info('Insert');
    $obj->set_parameter('j_id',0);
    $obj->save();
    $obj->load();
    var_dump($obj);

    echo h2info('Delete');
    $obj->delete();
    echo (($obj->load()==0)?'Trouve':'non trouve');
    var_dump($obj);
$cn->rollback();

  }

Definition at line 194 of file class_profile_menu_sql.php.

References $res, $sql, cn, and verify().

Referenced by save().

                           {
    if ( $this->verify() != 0 ) return;
    /*   please adapt */
    $sql=" update public.profile_menu set me_code = $1
,me_code_dep = $2
,p_id = $3
,p_order = $4
,p_type_display = $5
,pm_default = $6
 where pm_id= $7";
    $res=$this->cn->exec_sql(
                 $sql,
                 array($this->me_code
,$this->me_code_dep
,$this->p_id
,$this->p_order
,$this->p_type_display
,$this->pm_default
,$this->pm_id)
                 );
                 
  }

Definition at line 79 of file class_profile_menu_sql.php.

References trim().

Referenced by insert(), and update().

                           {
    // Verify that the elt we want to add is correct
    /* verify only the datatype */
     if ( trim($this->me_code) == '') $this->me_code=null;
 if ( trim($this->me_code_dep) == '') $this->me_code_dep=null;
 if ( trim($this->p_id) == '') $this->p_id=null;
if ( $this->p_id!== null && settype($this->p_id,'float') == false )
             throw new Exception('DATATYPE p_id $this->p_id non numerique');
 if ( trim($this->p_order) == '') $this->p_order=null;
if ( $this->p_order!== null && settype($this->p_order,'float') == false )
             throw new Exception('DATATYPE p_order $this->p_order non numerique');
 if ( trim($this->p_type_display) == '') $this->p_type_display=null;
 if ( trim($this->pm_default) == '') $this->pm_default=null;
if ( $this->pm_default!== null && settype($this->pm_default,'float') == false )
             throw new Exception('DATATYPE pm_default $this->pm_default non numerique');

    
  }

Field Documentation

Profile_Menu_sql::$variable [protected]
Initial value:
array("pm_id"=>"pm_id","me_code"=>"me_code"
,"me_code_dep"=>"me_code_dep"
,"p_id"=>"p_id"
,"p_order"=>"p_order"
,"p_type_display"=>"p_type_display"
,"pm_default"=>"pm_default"
)

Definition at line 41 of file class_profile_menu_sql.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations