Model::id PHP Method

id() public method

Get the database ID of this model instance.
public id ( ) : integer
return integer
    public function id()
    {
        return $this->orm->id();
    }

Usage Example

 public function insert($req)
 {
     try {
         $sql = 'INSERT INTO ' . $this->table . ' ';
         $variable = '( ';
         $valeur = '( ';
         foreach ($req as $k => $v) {
             $variable .= $k . ',';
             $valeur .= '"' . urlencode($v) . '",';
             //print_r($valeur);
         }
         //die('');
         $variable = trim($variable, ',');
         $variable .= ')';
         $valeur = trim($valeur, ',');
         $valeur .= ');';
         $sql .= $variable . ' VALUES ' . $valeur;
         //die($sql);
         @($insert = $this->db->exec($sql));
         if (!$insert) {
             $_SESSION["ErrorInsert"] = true;
         }
         Model::$id = $this->db->lastInsertId();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     Model::$connections[$this->conf] = null;
 }
All Usage Examples Of Model::id