• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Flash builder + Zend amf | Insertion function not working when called second time

New Here ,
Jun 06, 2012 Jun 06, 2012

Copy link to clipboard

Copied

I'm using standart createOrders function which is autogenerated by Flash Builder 4.6. It works brilliantly when used once. Here is code:

protected function okButton_clickHandler():void

            {

                var orders2:Orders = new Orders();

                //setting values

                createOrdersResult.token = ordersService.createOrders(orders2);

                ordersService.commit();

            }

When same button is clicked second time and consequently okButton_clickHandler launched, data is not inserted to database. I added result handler with trace("saved"); and what I saw was that "saved" was written on first click, but not second.

Also I used Charles to see whether request is being sent second time. And no it is not.

Just tried to generate auto generate form. Only had to add commit(); because else request is not sent. And here is save problem — request is sent only on first button click.

So all in all problem is in fact that ordersService.createOrders(orders2); works only once. Because if i try

createOrdersResult.token = ordersService.createOrders(orders2);

                ordersService.commit();

                createOrdersResult.token = ordersService.createOrders(orders2);

                ordersService.commit();

OR

            createOrdersResult.token = ordersService.createOrders(orders2);

            createOrdersResult.token = ordersService.createOrders(orders2);

            ordersService.commit();

there is only one row added to database. Any ideas?

TOPICS
PHP

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 04, 2012 Jul 04, 2012

Copy link to clipboard

Copied

Hi,

just try to use another instance of order, like this:

     var orders2:Orders = new Orders();

            createOrdersResult.token = ordersService.createOrders(orders2);

     var orders3:Orders = new Orders();

            createOrdersResult.token = ordersService.createOrders(orders3);

            ordersService.commit();

It will work well!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

Think you can find the problem in your php / whatever -backend. Generated code does'nt much know about autoincrement table ids.

So for the example tabel orders:

orderID int(10) auto_increment

orderName varchar(255)

...generated php for createOrders looks like:

$stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (orderID, orderName) VALUES (?, ?)");

mysqli_stmt_bind_param($stmt, 'is', $item->orderID, $item->orderName);

So if you dont give the right orderID, the second insert will fail.

Delete the autoincrement parts and code will work:

$stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (orderID, orderName) VALUES (?, ?)");

mysqli_stmt_bind_param($stmt, 'is', $item->orderID, $item->orderName);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2013 Mar 07, 2013

Copy link to clipboard

Copied

LATEST

Hey dude try this.

     var orders2:Orders = new Orders();

     orders2:YOUR_FIELD_NAME = YOUR_TEXTINPUT_ID.text;

     createOrdersResult.token = ordersService.createOrders(orders2);

     ordersService.commit();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines