1
0
mirror of synced 2024-12-16 16:16:04 +03:00
doctrine2/manual/docs/Working with objects - Component overview - Record - Creating new records.php

25 lines
603 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
There are couple of ways for creating new records. Propably the easiest is using
native php new -operator. The other ways are calling Doctrine_Table::create() or Doctrine_Connection::create().
The last two exists only for backward compatibility. The recommended way of creating new objects is the new operator.
<code type="php">
$user = $conn->create("User");
// alternative way:
$table = $conn->getTable("User");
$user = $table->create();
// the simpliest way:
$user = new User();
// records support array access
$user["name"] = "John Locke";
// save user into database
$user->save();
</code>