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

Manage the table public.menu_ref. More...

Inheritance diagram for Menu_Ref_sql:
Extension Menu_Ref

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
 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.menu_ref.

Definition at line 33 of file class_menu_ref_sql.php.


Constructor & Destructor Documentation

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

Definition at line 48 of file class_menu_ref_sql.php.

References $value, cn, and load().

        {
                $this->cn = $p_cn;
                $this->me_code = $p_id;

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

                        $this->load();
                }
        }

Member Function Documentation

Definition at line 246 of file class_menu_ref_sql.php.

References $res, $sql, and cn.

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

Definition at line 90 of file class_menu_ref_sql.php.

        {
                return var_export($this, true);
        }
Menu_Ref_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 139 of file class_menu_ref_sql.php.

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

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

Definition at line 68 of file class_menu_ref_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 151 of file class_menu_ref_sql.php.

References $sql, cn, and verify().

Referenced by Extension\insert_plugin().

        {
                if ($this->verify() != 0)
                        return;

                        $sql = "insert into public.menu_ref(me_menu
                                        ,me_file
                                        ,me_url
                                        ,me_description
                                        ,me_parameter
                                        ,me_javascript
                                        ,me_type
                                        ,me_code) values ($1
                                        ,$2
                                        ,$3
                                        ,$4
                                        ,$5
                                        ,$6
                                        ,$7
                                        ,$8
                                        ) returning me_code";

                        $this->me_code = $this->cn->get_value(
                                        $sql, array($this->me_menu
                                , $this->me_file
                                , $this->me_url
                                , $this->me_description
                                , $this->me_parameter
                                , $this->me_javascript
                                , $this->me_type
                                , $this->me_code)
                        );

        }

load a object

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

Definition at line 215 of file class_menu_ref_sql.php.

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

Referenced by __construct(), and Extension\search().

        {

                $sql = "select me_menu
                                                ,me_file
                                                ,me_url
                                                ,me_description
                                                ,me_parameter
                                                ,me_javascript
                                                ,me_type
                                                 from public.menu_ref where me_code=$1";
                /* please adapt */
                $res = $this->cn->get_array(
                                $sql, array($this->me_code)
                );

                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;
        }
Menu_Ref_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 123 of file class_menu_ref_sql.php.

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

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

Definition at line 79 of file class_menu_ref_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 Menu_Ref_sql::test_me ( ) [static]

Unit test for the class.

Definition at line 255 of file class_menu_ref_sql.php.

        {
        }

Definition at line 186 of file class_menu_ref_sql.php.

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

Referenced by Extension\update_plugin().

        {
                if ($this->verify() != 0)
                        return;
                /*   please adapt */
                $sql = " update public.menu_ref set me_menu = $1
                                        ,me_file = $2
                                        ,me_url = $3
                                        ,me_description = $4
                                        ,me_parameter = $5
                                        ,me_javascript = $6
                                        ,me_type = $7
                                         where me_code= $8";
                $res = $this->cn->exec_sql(
                                $sql, array($this->me_menu
                        , $this->me_file
                        , $this->me_url
                        , $this->me_description
                        , $this->me_parameter
                        , $this->me_javascript
                        , $this->me_type
                        , $this->me_code)
                );
        }

Reimplemented in Extension, and Menu_Ref.

Definition at line 95 of file class_menu_ref_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_menu) == '')
                        $this->me_menu = null;
                if (trim($this->me_file) == '')
                        $this->me_file = null;
                if (trim($this->me_url) == '')
                        $this->me_url = null;
                if (trim($this->me_description) == '')
                        $this->me_description = null;
                if (trim($this->me_parameter) == '')
                        $this->me_parameter = null;
                if (trim($this->me_javascript) == '')
                        $this->me_javascript = null;
                if (trim($this->me_type) == '')
                        $this->me_type = null;
        }

Field Documentation

Menu_Ref_sql::$variable [protected]
Initial value:
 array(
                "me_code" => "me_code"
                , "me_menu" => "me_menu"
                , "me_file" => "me_file"
                , "me_url" => "me_url"
                , "me_description" => "me_description"
                , "me_parameter" => "me_parameter"
                , "me_javascript" => "me_javascript"
                , "me_type" => "me_type"
        )

Definition at line 37 of file class_menu_ref_sql.php.


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