Skip to content

RDNBASE - this is a base template for your frontend and backend applications using PHP, MYSQL and Bootstrap in the MVC standard, using good practices to create your applications in an organized manner.

Notifications You must be signed in to change notification settings

rodineiti/base-php-mysql-bootstrap

Repository files navigation

RDNBASE

this is a base template for your frontend and backend applications using PHP, MYSQL and Bootstrap in the MVC standard, using good practices to 
create your applications in an organized manner.

Clone the repository

git clone [email protected]:rodineiti/base-php-mysql-bootstrap.git base

Switch to the repo folder

cd base
cp config-example.php config.php
cp htaccess-example.txt .htaccess

Edit file config.php, and set connection mysql

$config["dbname"] = "database_base";
$config["dbhost"] = "mysql";
$config["dbuser"] = "root";
$config["dbpass"] = "root";

Dump file database_base.sql into database

Run server php or your server (Wamp, Mamp, Xamp), and open in the browser localhost

php -S localhost

Url ADMIN:

Admin login: http://localhost/base/admin/login

login: [email protected]
password: 123456

LOGIN USER:

login: http://localhost/base/login

login: [email protected]
password: 123456

Selects

<?php
use Src\Models\User;

// get one with where - alternative find one
$model = new User();
$user = $model->select(["id", "name"])->where("name", "=", "Fulano")->fisrt();

var_dump($user);

// get all with get - alternative find all
$model = new User();
$users = $model->select()->all();

var_dump($users);

findById

<?php
use Src\Models\User;

$model = new User();
$user = $model->getById(2);
echo $user->name;

count

<?php
use Src\Models\User;
$model = new User();

$count = $model->select()->count();

wheres

<?php
use Src\Models\User;
$model = new User();

// find with where
$users = $model
    ->select()
    ->where("id", ">", 1)
    ->where("name", "=", "teste")
    ->all();

var_dump($users);

$model = new User();
// find with whereRaw
$users = $model
    ->select()
    ->whereRaw("name LIKE '%fulano%' ")
    ->all();

var_dump($users);

$model = new User();
// find with whereIn
$users = $model
    ->select()
    ->whereIn("id", [1,2])
    ->all();

var_dump($users);

joins

<?php
use Src\Models\User;

$model = new User();
// find with join address
$users = $model
    ->select()
    ->join("address", "user_id", "id")
    ->all();

var_dump($users);

// find with join address conditions
$users = $model
    ->select()
    ->join("address", function ($query) {
        $query->on("address.user_id", "=", "users.id");
    })
    ->all();

var_dump($users);

$model = new User();
// find with left join address
$users = $model
    ->select()
    ->leftJoin("address", "user_id", "id")
    ->all();

var_dump($users);

$model = new User();
// find with right join address
$users = $model
    ->select()
    ->rightJoin("address", "user_id", "id")
    ->all();

var_dump($users);

Prints:

Home

image

Dashboard Admin

image

About

RDNBASE - this is a base template for your frontend and backend applications using PHP, MYSQL and Bootstrap in the MVC standard, using good practices to create your applications in an organized manner.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages