PHP code example of phiconsultors / gcf

1. Go to this page and download the library: Download phiconsultors/gcf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phiconsultors / gcf example snippets




/**
 * Application initialization
 */

use gcf\Environment;

h (Exception $ex) {
        die($ex->getMessage());
}

$myQuery = new SQLQuery($db);
$myQuery->fer_consulta("select ID, USER, NAME from user where id=3");

while(!$consulta->Eof())
{
    $user = $consulta->row['USER'];
    $name = $consulta->row['NAME'];
    
    $consulta->Skip();
}

$consulta->tanca_consulta();

$myQuery = new SQLQuery($db);
$myQuery->PrepareQuery("select ID, USER, NAME from user where id=3");

foreach (new ResultSet($myQuery, "ID") as $record)
{
    // Can access each field with, for example: $record->USER or $record->NAME and so on.
}

class MyAppDataMapper extends DataMapper
{
    /**
     * @var DatabaseConnector
     */
    protected DatabaseConnector $dbContext;

    /**
     * @throws errorDatabaseConnection
     * @throws errorDriverDB
     * @throws errorDatabaseAutentication
     */
    public static function GetDBContext() : DatabaseConnector
    {
        $dbPool = connectionPool::getInstance();
        return $dbPool->maindbname->getConnection();
    }

    /**
     * Data\models\taulaBDPersonal constructor.
     * @param string $tableName
     * @param mixed $pk
     * @param mixed $pkType
     * @throws errorDatabaseAutentication
     * @throws errorDatabaseConnection
     * @throws errorDriverDB
     */
    public function __construct(string $tableName, $pk, $pkType)
    {
        $this->dbContext = self::GetDBContext();
        parent::__construct($this->dbContext, $tableName, $pk, $pkType);
    }

class User extends MyAppDataMapper
{
    public function __construct($tableName="USER", $pk="ID", $pkType="int") 
    {
        parent::__construct($tableName, $pk, $pkType);
    }
}

/**
 * Class User
 * @property int ID
 * @property string USER
 * @property string NAME
 */
class User extends MyAppDataMapper
{
    public function __construct($tableName="USER", $pk="ID", $pkType="int") 
    {
        parent::__construct($tableName, $pk, $pkType);
    }
}

$user = new User();
$user->ID = 3;
$user->USER = "tomeu";
$user->NAME = "Tomeu Capó";
$user->Nou();

$user = new User();
$user->Borra(3);

$user = new User();
$user->NAME="Pep";
$user->Modifica(3);

Myapp
│   composer.json
│   init.php
├───cfg
│   └───properties_dev.ini
├───app
├───data
│   └───models
└───frontal
    │   index.php
    │
    ├───cfg
    ├───modules
    ├───static
    │   ├───css
    │   ├───img
    │   └───jscript
    └───templates
            index.twig