Sisäänkirjautuminen| Uusi tunnus
FrontPage| Projects| Forums| Search|
^ DaoGen Forums: › Why? › PHP5? › Using ToString() with PHP › Next DaoGen version almost ready! » Create (insert) and Save (update) PHP examples › Support for numeric object types almost ready! › DaoGen 2.1.0 released! › Compliments and minor suggestion › variables within a class › Foreign key constraint in create() › Security issue!!! › auto-generated columns and create method › Oracle BLOB › DAO for cross-table queries › Please help me.. › Please use this forum for DaoGen related stuff › Call-time Pass-By-Reference › DaoGen 2.4.0 has been released! › How can I show relationships? › DaoGen & PHP 5 › PHP4 vs PHP5 and other considerations. › singleQuery example in php › Why are save and delete not synchronized? › Why are save and delete not synchronized? › DTD for generated XML › DaoGen 2.2.2 has been released! › DaoGen 2.0.2 is available. › For a thesis ?? › Extremely good idea ?? how can I ???? › Usability suggestions for DaoGen › Performance of DaoGen with Mapping tools › Performance with List › Some usage statistics › DaoGen 2.2.1 has been released! › Programming Examples are back! › DaoGen 2.0.1 is available. › Version 2.0.0 generates buggy PHP code! New version soon available! › Examples of DaoGen customizations › Code Examples
Sisäänkirjautuminen
» Käyttäjätunnus:
» Salasana:
» Muista kirjautuminen:
Suosituimmat sivut: › DaoGen 2.1.0 released! › Using ToString() with PHP › DaoGen Forums › Programming Examples › DaoGen Manual › DaoGen FAQ › Search › Projects › Forums › Version 2.0.0 generates buggy PHP code! New version soon available!
FrontPage » Forums » DaoGen Forums » Create (insert) and Save (update) PHP examples

Create (insert) and Save (update) PHP examples

Posted by anonymous 20.07.2004 00:46

Some PHP code examples to Create and Save a record would be useful.

Thanks for the great tool.


Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 21.07.2004 22:36

This is just a quick follow-up to my previous message.

Using the column names found in DaoGen's loadall() example, here's how to create (insert) and save (update) a record with PHP.

With data POSTed from a form, set the property values then use the "create" method:

$Customer = new Customer();

$Customer->setCreated($_POST['Created']);
$Customer->setCompanyName($_POST['CompanyName']);
$Customer->setNumber($_POST['Number']);
$Customer->setAddress($_POST['Address']);
$Customer->setBalance($_POST['Balance']);

$customerHandler->create($connection, $Customer);


To update a record, set the ID property value then use the "save" method.

$Customer = new Customer();

$Customer->setID($_POST['ID']);
$Customer->setCreated($_POST['Created']);
$Customer->setCompanyName($_POST['CompanyName']);
$Customer->setNumber($_POST['Number']);
$Customer->setAddress($_POST['Address']);
$Customer->setBalance($_POST['Balance']);

$customerHandler->save($connection, $Customer);


This might be obvious to many, but maybe it'll save others some time.


Re: Create (insert) and Save (update) PHP examples

Posted by Luigi 23.07.2004 16:28

> anonymous 20.07.2004 00:46
> Some PHP code examples to Create and Save a record would be useful.

You are right about examples. I am planning to write more examples, but somehow something else seems allways more important/interesting to do. My programming efforts are mostly targeted to enhance FastCMS and it still has quite a lot to do. However, I promise that I will try to find some time for the examples.

> Thanks for the great tool.

Thanks for good feedback, I hope you will find DaoGen useful!

// Luigi


CRUD Application Generation

Posted by anonymous 16.07.2005 06:10

If CRUD application can also be generated,
That's great!


Re: CRUD Application Generation

Posted by Luigi 07.08.2005 14:18

I am sorry, but I have no idea of what is GRUD application.

// Luigi


Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 08.09.2005 12:15

> anonymous 21.07.2004 22:36
> [...]
>
> $Customer->setNumber($_POST['Number']);
> [...]
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->create($connection, $Customer);
>
>
> To update a record, set the ID property value then use the "save" method.
>
> $Customer = new Customer();
>
> $Customer->setID($_POST['ID']);
> $Customer->setCreated($_POST['Created']);
> $Customer->setCompanyName($_POST['CompanyName']);
> [...]
> $Customer->setAddress($_POST['Address']);
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->save($connection, $Customer);

Relating to the above:

How does DaoGen generated code behave in reference to NULL fields?

Does it retrieve and store them correctly?

Or does it transform NULL to '' (<--- empty string)?


Re: Re: Re: Create (insert) and Save (update) PHP examples

Posted by Luigi 14.09.2005 12:29

Hello,

NULL values are no problem when you use object types when defining the database structure. Strings are allways objects and they behave always correctly with NULL values but for numeric types you must use spesific object versions for these types. The general idea with object types is that NULL values are preserved. With primitive types (the opposite of object type) NULL values are converted to 0.

// Luigi


Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:30

> anonymous 21.07.2004 22:36
> This is just a quick follow-up to my previous message.
>
> Using the column names found in DaoGen's loadall() example, here's how to create (insert) and save (update) a record with PHP.
>
> With data POSTed from a form, set the property values then use the "create" method:
>
> $Customer = new Customer();
>
> $Customer->setCreated($_POST['Created']);
> $Customer->setCompanyName($_POST['CompanyName']);
> $Customer->setNumber($_POST['Number']);
> $Customer->setAddress($_POST['Address']);
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->create($connection, $Customer);
>
>
> To update a record, set the ID property value then use the "save" method.
>
> $Customer = new Customer();
>
> $Customer->setID($_POST['ID']);
> $Customer->setCreated($_POST['Created']);
> $Customer->setCompanyName($_POST['CompanyName']);
> $Customer->setNumber($_POST['Number']);
> $Customer->setAddress($_POST['Address']);
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->save($connection, $Customer);
>
>
> This might be obvious to many, but maybe it'll save others some time.


Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:30




Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:36

> anonymous 20.07.2004 00:46
> Some PHP code examples to Create and Save a record would be useful.
>
> Thanks for the great tool.


Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:36

> anonymous 21.07.2004 22:36
> This is just a quick follow-up to my previous message.
>
> Using the column names found in DaoGen's loadall() example, here's how to create (insert) and save (update) a record with PHP.
>
> With data POSTed from a form, set the property values then use the "create" method:
>
> $Customer = new Customer();
>
> $Customer->setCreated($_POST['Created']);
> $Customer->setCompanyName($_POST['CompanyName']);
> $Customer->setNumber($_POST['Number']);
> $Customer->setAddress($_POST['Address']);
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->create($connection, $Customer);
>
>
> To update a record, set the ID property value then use the "save" method.
>
> $Customer = new Customer();
>
> $Customer->setID($_POST['ID']);
> $Customer->setCreated($_POST['Created']);
> $Customer->setCompanyName($_POST['CompanyName']);
> $Customer->setNumber($_POST['Number']);
> $Customer->setAddress($_POST['Address']);
> $Customer->setBalance($_POST['Balance']);
>
> $customerHandler->save($connection, $Customer);
>
>
> This might be obvious to many, but maybe it'll save others some time.


Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:37

> Luigi 23.07.2004 16:28
> > anonymous 20.07.2004 00:46
> > Some PHP code examples to Create and Save a record would be useful.
>
> You are right about examples. I am planning to write more examples, but somehow something else seems allways more important/interesting to do. My programming efforts are mostly targeted to enhance FastCMS and it still has quite a lot to do. However, I promise that I will try to find some time for the examples.
>
> > Thanks for the great tool.
>
> Thanks for good feedback, I hope you will find DaoGen useful!
>
> // Luigi


Re: CRUD Application Generation

Posted by anonymous 29.05.2006 04:37

> anonymous 16.07.2005 06:10
> If CRUD application can also be generated,
> That's great!


Re: Re: Re: Create (insert) and Save (update) PHP examples

Posted by anonymous 29.05.2006 04:37

> anonymous 08.09.2005 12:15
> > anonymous 21.07.2004 22:36
> > [...]
> >
> > $Customer->setNumber($_POST['Number']);
> > [...]
> > $Customer->setBalance($_POST['Balance']);
> >
> > $customerHandler->create($connection, $Customer);
> >
> >
> > To update a record, set the ID property value then use the "save" method.
> >
> > $Customer = new Customer();
> >
> > $Customer->setID($_POST['ID']);
> > $Customer->setCreated($_POST['Created']);
> > $Customer->setCompanyName($_POST['CompanyName']);
> > [...]
> > $Customer->setAddress($_POST['Address']);
> > $Customer->setBalance($_POST['Balance']);
> >
> > $customerHandler->save($connection, $Customer);
>
> Relating to the above:
>
> How does DaoGen generated code behave in reference to NULL fields?
>
> Does it retrieve and store them correctly?
>
> Or does it transform NULL to '' (<--- empty string)?