Skip to content

iscod/GoMoney

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status FOSSA Status

What GoMoney

Open PHP Framework

Links

Documentation

Installation

git clone https://github.com/IsCod/GoMoney.git
cd GoMoney
composer install

License

FOSSA Status

Route

config

route.ini file in App\config\route.ini

add route

you can add code in route.ini

[Welcome/index]
uri=Welcome/index
action=Welcome/index
method[]=GET
method[]=POST

Controller

Controller is route.ini uri map action

eq.

route.ini have code:

[Welcome/index]
uri=Welcome/index
action=Welcome/index
method[]=GET
method[]=POST

new Welcome.php file

touch App/Controller/Welcome.php

edit code in Welcome.php

<?php

namespace App\Controller;

use GoMoney\Controller;

class Welcome extends Controller
{
    public function index()
    {
        echo "Hello World!";
    }
}

Access to web http://example.com/welcome/index

You see

Hello World!

DB

config

route.ini file in App\config\database.ini

add dbname

[dbname]
dsn=
driver=mysql
host=127.0.0.1
port=3306
database=database
username=root
password=

connect db

/**
 * @param null $database
 * @return object DB
 */
$db = DB::connect('dbname'); //return new pdo

table

/**
 * @param string $table
 * @param null $database
 * @return object DB
 */
$db = DB::connect('dbname')->table('tablename');

but you can method table realize

$db = DB::table('tablename', 'dbname');

insert

$id = DB::connect('dbname')->table('tablename')->insert(['a'=>'a']);

where

/**
 * @return array
 */
$db = DB::connect('dbname')->table('tablename')->where(['id' => 1])->get();

or

$db = DB::connect('dbname')->table('tablename')->where('id', '=', 1)->get();

eq (only =)

$db = DB::connect('dbname')->table('tablename')->where('id', 1)->get();

equivalent

$db = DB::connect('dbname')->table('tablename')->where('id', '=', 1)->get();

if you get limit you can use method limit

$db = DB::connect('dbname')->table('tablename')->where(['id' => 1])->limit(1)->get();

if you limit 1, you can method getOne()

/**
 * @return array
 */
$db = DB::connect('dbname')->table('tablename')->where(['id' => 1])->getOne();

exec

exec for SQL statement

$db = DB::connect('dbname')->exec('SHOW TABLES');

Todo

1, Route use registered 2, Error manage