|
Method save ( $oData = NULL, $bForceCreate = false ) |
|
Written by Hidalgo Emmanuel
|
Description : This method safeguards the properties of an object in the database. Parameters : $oData (optional), array of key / value : This parameter can contain key pairs/value or key/object. The properties of the object will be updated before its recording. $bForceCreate (optional), boolean : This parameter and used during the creation of object not comprising a numerical primary key. By putting the parameter at “true”, the object will be created in the database. Value of return : No parameter of return. The following example illustrates the recording of a product with an update of certain properties : <?php //total instanciation include_once( 'phpsimpledb.class.php' ); Global $oBDD; $oBDD = new PHPSIMPLEDB(); //recovery of the product $oProduit = $oBDD->getObject( "produits" ); $oProduit->load( 2 ); //creation a new "user" $oUser = $oBDD->getObject( "users" ); $oUser->setData_field( "name", "John Do" ); $oUser->setData_field( "level", 80 ) ; //update of the product $oProduit->save( array( "name"=>"Jolie maison de campagne", "users_id"=>$oUser ) );
?> |
|