Open PHP Framework
git clone https://github.com/IsCod/GoMoney.git
cd GoMoney
composer install
route.ini file in App\config\route.ini
you can add code in route.ini
[Welcome/index]
uri=Welcome/index
action=Welcome/index
method[]=GET
method[]=POST
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!
route.ini file in App\config\database.ini
[dbname]
dsn=
driver=mysql
host=127.0.0.1
port=3306
database=database
username=root
password=
/**
* @param null $database
* @return object DB
*/
$db = DB::connect('dbname'); //return new pdo
/**
* @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');
$id = DB::connect('dbname')->table('tablename')->insert(['a'=>'a']);
/**
* @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 for SQL statement
$db = DB::connect('dbname')->exec('SHOW TABLES');
1, Route use registered 2, Error manage