PHP code example of pinahq / framework

1. Go to this page and download the library: Download pinahq/framework 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/ */

    

pinahq / framework example snippets


\Pina\Config::get(‘db’, ‘user’);



namespace Pina\Modules\Images;

use Pina\ModuleInterface;
use Pina\Event;

class Module implements ModuleInterface
{

    public function getPath()
    {
        return __DIR__;
    }
    
    public function getNamespace()
    {
        return __NAMESPACE__;
    }

    public function getTitle()
    {
        return 'Images';
    }
    
    public function boot()
    {
        Event::subscribe($this, 'image.resize');
    }

    public function http()
    {
        return [
            'cp/images',
            'images',
        ];
    }
    
    public function cli()
    {
        return [
            'image',
        ];
    }

}

function __($string)
{
    return \Pina\Language::translate($string, __NAMESPACE__);
}

{link_context author_id=$filter.author_id sort=$sort}
  <ul class="nav">
    {section loop=$pages name=page}
      <li><a href="{link get="books" page=$page}"></a></li>
    {/section}
  </ul>
{/link}

return array(
    'default' => array(
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'root',
        'base' => 'pina2',
        'charset' => 'utf8',
    )
);

$db = App::container()->get(\Pina\DatabaseDriverInterface::class);
$data =$db->table("SELECT * FROM products");

$db = App::container()->get(\Pina\DatabaseDriverInterface::class);
$db->query("INSERT INTO products SET title='test'");
$id = $db->insertId();

$users = SQL::table('cody_user')->get();

$user = SQL::table('cody_user')->whereBy("user_login", "admin")->first();

$isEnabled = SQL::table('cody_user')->whereBy("user_login", "admin")->value(‘user_enabled’);

$users = SQL::table('cody_user')->select('user_login')->select('user_email')->get();

SQL::table('cody_user')->where("user_expired > '2015-03-01'")->whereBy('user_enabled', 'Y')->get();

SQL::table('cody_user')->orderBy('user_created desc')->groupBy('user_id')->calculate('count(cody_account.*) as cnt')->having('cnt > 5')->get();

SQL::table('cody_user')->limit(30, 10)->get();
SQL::table('cody_user')->limit(10)->get();

if (SQL::table('cody_user')->whereBy('user_login', 'test')->exists()) {
    echo 'exists!';
}

SQL::table('cody_user')->whereBy('user_login', 'test')->update(['user_email' => '[email protected]']);