1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/docs/Working with objects - Component overview - Record - Creating new records.php
2007-04-13 21:49:11 +00:00

25 lines
603 B
PHP

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>