ORM::for_table PHP Method

for_table() public static method

Despite its slightly odd name, this is actually the factory method used to acquire instances of the class. It is named this way for the sake of a readable interface, ie ORM::for_table('table_name')->find_one()-> etc. As such, this will normally be the first method called in a chain.
public static for_table ( string $table_name, string $connection_name = self::DEFAULT_CONNECTION ) : ORM
$table_name string
$connection_name string Which connection to use
return ORM
    public static function for_table($table_name, $connection_name = self::DEFAULT_CONNECTION)
    {
        self::_setup_db($connection_name);
        return new self($table_name, array(), $connection_name);
    }

Usage Example

Exemplo n.º 1
0
 public function update($table, $id, $ignore_keys = null)
 {
     if ($_POST) {
         $params = $_POST;
         $this->crud->save($table, $params, $id);
         $this->view = new Create('done');
     } else {
         $fields = \ORM::for_table($table)->raw_query('DESCRIBE ' . $table)->find_array();
         $row = $this->crud->read($table, $id);
         if ($ignore_keys) {
             foreach ($row as $key => $value) {
                 if (in_array($key, $ignore_keys)) {
                     unset($row[$key]);
                 }
             }
             foreach ($fields as $key => $field) {
                 if (in_array($field['Field'], $ignore_keys)) {
                     unset($fields[$key]);
                 }
             }
         }
         $data['fields'] = $fields;
         $data['row'] = $row;
         $this->view = new Update('update', $data);
     }
 }
All Usage Examples Of ORM::for_table
ORM