Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 17 of 17 total
Thread Mysql PHP Json format problem with DateTime
Thu, Oct 29 2015 10:20 AMPermanent Link

D.C.

Hi Pasquale,

This may help:

       //For accurate milliseconds calculation
   date_default_timezone_set('America/Argentina/Buenos_Aires'); //replace with your TZ

   while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
    {
          //there is a date field?
       for ($i=0; $i<count($row); $i++){
         $finfo = mysqli_fetch_field_direct($result, $i);
         //12=datetime 10=date
         if ($finfo->type==12 or $finfo->type==10){
            $campofecha = strtotime($row[$finfo->name])*1000;
            $row[$finfo->name] = $campofecha;
         }
      }
      $rows[] = $row;
   }


Another suggestion, convert dates to strings in MySQL statements. This also helps to display dates properly formatted in EWB grids. When you need to perform calculations in EWB code, use StrToDate.
I´m working this way now because I use DreamFactory REST API, and dates are given as strings.

Hope this help.

Regards
Diego
Thu, Oct 29 2015 1:01 PMPermanent Link

Pasquale

Web Pos srl

perfect ... tanks very goooodddddd



D.C. wrote:

Hi Pasquale,

This may help:

       //For accurate milliseconds calculation
   date_default_timezone_set('America/Argentina/Buenos_Aires'); //replace with your TZ

   while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
    {
          //there is a date field?
       for ($i=0; $i<count($row); $i++){
         $finfo = mysqli_fetch_field_direct($result, $i);
         //12=datetime 10=date
         if ($finfo->type==12 or $finfo->type==10){
            $campofecha = strtotime($row[$finfo->name])*1000;
            $row[$finfo->name] = $campofecha;
         }
      }
      $rows[] = $row;
   }


Another suggestion, convert dates to strings in MySQL statements. This also helps to display dates properly formatted in EWB grids. When you need to perform calculations in EWB code, use StrToDate.
I´m working this way now because I use DreamFactory REST API, and dates are given as strings.

Hope this help.

Regards
Diego
Thu, Oct 29 2015 1:04 PMPermanent Link

Pasquale

Web Pos srl

I'm sorry I'm implementing a commit in php


if ($method == 'commit')
 {

    $json = file_get_contents( 'php://input' );

    $DecodedOperazioni = json_decode($json, True);

    $Operazioni = $DecodedOperazioni['operations'];

    for ($i = 0; $i < count($Operazioni); $i++)
    {

      $Operazione = $Operazioni[$i];
      $Dataset    = $Operazione['dataset'];

      $TipoOperazione = $Operazione['operation'];
      $RigaPrima      = $Operazione['beforerow'];
      $RigaDopo       = $Operazione['afterrow'];

      if ($TipoOperazione == '1')  

        {
      
        }
    }
 }


you have any suggestions for me ?
Thu, Oct 29 2015 3:13 PMPermanent Link

D.C.

>Pasquale wrote:

>I'm sorry I'm implementing a commit in php

>you have any suggestions for me ?


I developed several php that I called from EWB for all database operations, but it was very insecure. A lot of data was visible looking at browser network calls. I tried then to implement something with sessions and encryption.

In the meantime I found dreamfactory and make it work with EWB. It generates a complete REST API from the most popular databases SQL and NoSQL. It has a complete login, permissions and sessions management. I´m using it now for EWB and mobile, it is really great. My suggestion is to check it, I was able to convert my EWB calls to php very easily to DF.

It is opensource. You may start using the service provided by dreamfactory.com and once it works, migrate it to your own server.

Best wishes
Diego
Fri, Oct 30 2015 12:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Diego,

<< I developed several php that I called from EWB for all database operations, but it was very insecure. A lot of data was visible looking at browser network calls. >>

Just curious: what data are you referring to ?  The only data that should be visible is the actual JSON for the dataset rows/BLOB columns, and that is the case with any JSON API.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Oct 30 2015 1:31 PMPermanent Link

D.C.

>Just curious: what data are you referring to ?  The only data that should be visible is the actual JSON for the dataset >rows/BLOB columns, and that is the case with any JSON API.

Hi Tim,

I've sent the data in URL calls to php, like

dbselect.php?UserID=123

It was the first way I tried, and worked very well.

Regards
Diego
Fri, Oct 30 2015 2:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Diego,

<< I've sent the data in URL calls to php, like

dbselect.php?UserID=123

It was the first way I tried, and worked very well. >>

That will be fine, as long as you're using a secure connection (https):

http://stackoverflow.com/questions/499591/are-https-urls-encrypted

Of course, all of the caveats noted in the StackOverflow comments should be taken into account (server logs, etc.).

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image