<?php

$clause='1=1';

$field='';

$value='';

if($_a=='select'):

    if(isset($idUser)){

        $clause=" and idUser='$idUser";

    }

    if(isset($date_creat)){

        $clause=" and date_creat='$date_creat";

    }

    $sql="select * from updates where $clause";

    echo json_encode(rows($sql));

endif;

if($_a=='get'):

    $sql="select * from updates where id='$id'";

    echo json_encode(row($sql));

endif;

if($_a=='delete'):

    $sql="delete from updates where id='$id'";

    execute($sql);

endif;

if($_a=='insert'):

    $field="idUser,old_state,new_state";

    $value="'$idUser','$old_state','$new_state'";

    $sql="insert into updates($field) values($value)";

    echo execute($sql);

endif;