noalyss  Version-6.7.2
Public Member Functions
Tool_Uos Class Reference

Objec to check a double insert into the database, this duplicate occurs after a refresh of the web page in. More...

Public Member Functions

 __construct ($p_name)
 Constructor $p_name will be set to $this->name, it is also the name of the tag hidden in a form $cn Db connxion.
 check ($p_array=null)
 get_count ($p_array=null)
 Count how many time we have this->id into the table tool_uos $cn Database connx.
 hidden ()
 return a string with a tag hidden and a uniq value
 save ($p_array=null)
 Try to insert into the table tool_uos $cn Database connx.

Detailed Description

Objec to check a double insert into the database, this duplicate occurs after a refresh of the web page in.

Definition at line 34 of file class_tool_uos.php.


Constructor & Destructor Documentation

Tool_Uos::__construct ( p_name)

Constructor $p_name will be set to $this->name, it is also the name of the tag hidden in a form $cn Db connxion.

Parameters:
$p_name

Definition at line 42 of file class_tool_uos.php.

References name.

    {
        $this->name=$p_name;
    }

Member Function Documentation

Tool_Uos::check ( p_array = null)

Definition at line 91 of file class_tool_uos.php.

References $cn, $count, $e, $p_array, and name.

    {
        global $cn;
        if ( $p_array == null ) $p_array=$_POST;
        $this->id=$p_array[$this->name];
        try
        {
            $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
                    array($this->id));
            if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
        }catch (Exception $e)
        {
            throw $e;
        }
    }
Tool_Uos::get_count ( p_array = null)

Count how many time we have this->id into the table tool_uos $cn Database connx.

Parameters:
$p_arrayis the array where to find the key name, usually it is $_POST. The default value is $_POST
Returns:
integer : 0 or 1

Definition at line 82 of file class_tool_uos.php.

References $cn, $count, $p_array, and name.

    {
        global $cn;
        if ( $p_array == null ) $p_array=$_POST;
        $this->id=$p_array[$this->name];
        $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
                array($this->id));
        return $count;
    }

return a string with a tag hidden and a uniq value

Parameters:
$hHiddenis the name of the tag hidden
Returns:
string : tag hidden

Definition at line 51 of file class_tool_uos.php.

References $cn, and name.

    {
                global $cn;
        $this->id=$cn->get_next_seq('uos_pk_seq');
        return HtmlInput::hidden($this->name,$this->id);
    }
Tool_Uos::save ( p_array = null)

Try to insert into the table tool_uos $cn Database connx.

Exceptions:
Exceptionif the value $p_id is not unique

Definition at line 62 of file class_tool_uos.php.

References $cn, $e, $p_array, $sql, and name.

    {
        global $cn;
                if ( $p_array == null ) $p_array=$_POST;
                $this->id=$p_array[$this->name];
        $sql="insert into tool_uos(uos_value) values ($1)";
        try {
            $cn->exec_sql($sql,array($this->id));
        } catch (Exception $e)
        {
            throw new Exception('Duplicate value');
        }
    }

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