Granada\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

Beispiel #1
0
 public function testInstanceIdColumnThree()
 {
     $this->setUpIdColumnOverrides();
     ORM::for_table('widget_nozzle')->use_id_column('new_id')->find_one(5);
     $expected = "SELECT * FROM `widget_nozzle` WHERE `new_id` = '5' LIMIT 1";
     $this->assertEquals($expected, ORM::get_last_query());
     $this->tearDownIdColumnOverrides();
 }
All Usage Examples Of Granada\ORM::for_table
ORM