Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - Amilu1967

4
General Discussion / Re: PHPRAD Classic edition and Mobile App
Now  i need the retrieve record from the app of a table "alunni" in json format .
How to wirite a function to make this in ApiController ?
eg (http mysite/api/getAlunni )
Can provide me sample code ?
Thanks in advance
(i purchased PHPRad Classic Edition)
6
General Discussion / Re: PHPRAD Classic edition and Mobile App
Modified as :
Code: [Select]
function insertattendance()
    {
    if(!empty($_GET)){ // we check if the get variable is not empty.
        $table_data = array(
            "RFIDTAG" => $_GET['RFIDTAG'],
            "Data" => $_GET['Data'],
            "Ora" => $_GET['Ora'],
            "Stato" => $_GET['Stato']
        );
       
        $db = $this->GetModel();
        $db->insert("attendance", $table_data);
    }
    }

Now Work.

Thanks in advance.

Now How i can know If the operation is success ? is there a way ?
7
General Discussion / Re: PHPRAD Classic edition and Mobile App
This is the my ApiController.php file:

Code: [Select]
<?php

/**
 * Info Contoller Class
 * @category  Controller
 */

class ApiController extends BaseController
{

/**
* call model action to retrieve data
* @return json data
*/

function json($action, $arg1 = null, $arg2 = null)
{
$model = new SharedController;
$args = array($arg1, $arg2);
$data = call_user_func_array(array($model, $action), $args);
render_json($data);
}
function insertattendance()
{
    if(!empty($_GET)){ // we check if the get variable is not empty.
        $table_data = array(
            $_GET['RFIDTAG'],
            $_GET['Data'],
            $_GET['Ora'],
            $_GET['Stato']
        );

        $db = $this->GetModel();
        $db->insert("attendance", $table_data);
    }

}

This is the error produced:


Error Message
syntax error, unexpected end of file, expecting function (T_FUNCTION) or const (T_CONST)

File
C:\xampp\htdocs\alumniattendance\app\controllers\ApiController.php On Line 38

Stack Trace
1 unknown file(unknown line): autoloadController('ApiController')
2 unknown file(unknown line): spl_autoload_call('ApiController')
3 C:\xampp\htdocs\alumniattendance\system\Router.php(148): class_exists('ApiController', true)
4 C:\xampp\htdocs\alumniattendance\system\Router.php(109): Router->run('api/insertattendance/')
5 C:\xampp\htdocs\alumniattendance\index.php(106): Router->init()

Where i wrong ? Thanks in advance
After insert the lack  "}" now the erro is :


Error Message
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list'

File
C:\xampp\htdocs\alumniattendance\app\models\PDODb.php On Line 459

Stack Trace
1 C:\xampp\htdocs\alumniattendance\app\models\PDODb.php(459): PDOStatement->execute()
2 C:\xampp\htdocs\alumniattendance\app\models\PDODb.php(1151): PDODb->buildInsert('attendance', Array, 'INSERT')
3 C:\xampp\htdocs\alumniattendance\app\controllers\ApiController.php(34): PDODb->insert('attendance', Array)
4 C:\xampp\htdocs\alumniattendance\system\Router.php(196): ApiController->insertattendance()
5 C:\xampp\htdocs\alumniattendance\system\Router.php(109): Router->run('api/insertattendance/')
6 C:\xampp\htdocs\alumniattendance\index.php(106): Router->init()

my table "attendance" fields are : id , RFIDTAG , Data , Ora , Stato

8
General Discussion / Re: PHPRAD Classic edition and Mobile App
This is the my ApiController.php file:

Code: [Select]
<?php

/**
 * Info Contoller Class
 * @category  Controller
 */

class ApiController extends BaseController
{

/**
* call model action to retrieve data
* @return json data
*/

function json($action, $arg1 = null, $arg2 = null)
{
$model = new SharedController;
$args = array($arg1, $arg2);
$data = call_user_func_array(array($model, $action), $args);
render_json($data);
}
function insertattendance()
{
    if(!empty($_GET)){ // we check if the get variable is not empty.
        $table_data = array(
            $_GET['RFIDTAG'],
            $_GET['Data'],
            $_GET['Ora'],
            $_GET['Stato']
        );

        $db = $this->GetModel();
        $db->insert("attendance", $table_data);
    }

}

This is the error produced:


Error Message
syntax error, unexpected end of file, expecting function (T_FUNCTION) or const (T_CONST)

File
C:\xampp\htdocs\alumniattendance\app\controllers\ApiController.php On Line 38

Stack Trace
1 unknown file(unknown line): autoloadController('ApiController')
2 unknown file(unknown line): spl_autoload_call('ApiController')
3 C:\xampp\htdocs\alumniattendance\system\Router.php(148): class_exists('ApiController', true)
4 C:\xampp\htdocs\alumniattendance\system\Router.php(109): Router->run('api/insertattendance/')
5 C:\xampp\htdocs\alumniattendance\index.php(106): Router->init()

Where i wrong ? Thanks in advance
9
General Discussion / Re: PHPRAD Classic edition and Mobile App
@Amilu1967‍ it should look like this.
Code: [Select]
function insertattendance()
{
    if(!empty($_GET)){ // we check if the get variable is not empty.
        table_data = array(
            $_GET['RFIDTAG'],
            $_GET['Data'],
            $_GET['Ora'],
            $_GET['Stato']
        );

        $db = $this->GetModel();
        $db->insert("attendance", $table_data);
    }
}

make changes, call http://localhost/alumniattendance/api/insertattendance/?RFIDTAG=9999999&Data=22/12/2020&Ora=11:00:00&Stato=Ingresso return error 500
10
General Discussion / Re: PHPRAD Classic edition and Mobile App
@Amilu1967‍ you can create your API in the ApiContrller.php in the app/controllers/ folder. Here you can find more info on creating the API function Adding cusotm button php (phprad.com).
can provide me sample code based on my api request ? Thanks in davance
i create this in apicontroller.php but not work:

function insertattendance()
   {
   
   table_data = array(
    $modeldata['RFIDTAG'],
    $modeldata['Data'],
    $modeldata['Ora'],
    $modeldata['Stato']);
   
$db->insert("attendance", $table_data);
}
can help me? thanks
12
General Discussion / PHPRAD Classic edition and Mobile App
Hello, i download the trial 30 day of PHPRad classic edition
I create a database sample with a table "attendance" with fields id,RFIDTAG,Data,Ora,Stato
I will to use api request to add a record from a mobile app call add post method.
My http request is http://localhost/alumniattendance/attendance/add?RFIDTAG=11111&Data=22/12/2020&Ora=11:00:00&Stato=Ingresso

When i call it i was redirect to add page and the fields ar correct populate with the value.

How can perform submission in table automatically ? Actually i need to press to button submit in order to write value to table, but i will add record automatically aftere call the post method . Is possible ? Can provide me sample code ? Thanks in advance.