function __construct() { $seo = array(); $seo['seo_title'] = 'Пользователи'; Funcs::setMeta($seo); if (is_numeric(Funcs::$uri[1]) && !Funcs::$uri[2]) { $data = User::getOne(Funcs::$uri[1]); $data['list'] = Catalog::getUserBooksList(Funcs::$uri[1]); View::render('user/one', $data); } }
static function createSession($email, $password) { if (empty($email) || empty($password)) { return false; } $user = User::getOne(array('email' => $email, 'password' => self::encryptPassword($password))); if (!$user) { return false; } $_SESSION['user_id'] = $user->id; return $user; }
public function model() { header('Last-Modified:' . date(DATE_RFC822)); tools::markTime('test'); Loader::model('User'); // $user = new User; // $user->name = 'imp'; // $user->age = 1; // $user->save(); // $db = DB::connection()->db(); // $db->setTable('user'); // $db->beginTransaction(); // $db->insert('user', array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456)); // $db->insert('user', array('username' => 'air5', 'password' => 123456)); // //$db->commit(); // $db->rollback(); // die(); // DB::begin(); // $res = DB::table('user')->insert(array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456)); // $res2 = DB::table('user')->insert(array('id' => 6, 'username' => 'air5', 'password' => 123456)); // //DB::commit(); // //DB::rollback(); // die(); DB::transaction(function () { $res = DB::table('user')->insert(array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456)); $res2 = DB::table('user')->insert(array('username' => 'air5', 'password' => 123456)); }); die; tools::markTime('init2'); $res = DB::table('test')->join('user')->on('user', 'test.id', '=', 'user.id')->leftJoin('test2')->on('test2', 'test2.id', '=', 'test.id')->all(); hprint($res, 1); //hprint($_SERVER, 1); $res = User::find(5); hprint($res); tools::markTime('init2.2'); $res = User::where(array('id' => 6))->get(); hprint($res); $user = new User(); tools::markTime('init4'); $res = $user->getOne(); hprint($res); //$res = user::all(); //$res = User::where(array('id' => 3))->all(); //$res = User::create(array('username' => 'imp_' . mt_rand(1000, 9999), 'password' => 123456, 'time' => time()), true); //hprint($res); $user->all1(); //$res = DB::table('test')->where(array('id' => 1))->get(); // DB::connection('imp'); // $res2 = DB::table('system_user')->where(array('id' => 1))->get(); // hprint($res2); tools::markTime('init3'); echo tools::showTime(); }
$dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); // MySQL config example // Make sure you have a mysql database connection available // And that the connected database has a users table with id, name, address, company and age // As culumns // Fill in the fields below with the relevant ones $mysqlConfig = ["type" => getenv('DB_TYPE'), "database" => getenv('DB_NAME'), "user" => getenv('DB_USER'), "password" => getenv('DB_PASS'), "host" => getenv('DB_HOST')]; // Make sure you choose the correct config type $conn = new Connection($mysqlConfig); // Get all users from the users table $users = User::getAll(); echo '<h3>All Users</h3>'; prettyPrint($users); // Get one user from the users table $user = User::getOne(3); // echo '<h3>One User</h3>'; prettyPrint($user); // Create a new user $user = new User(); $user->name = "Jin Kazama"; $user->age = 21; $user->address = "525 Kindaruma"; $user->company = "466 Video Productions"; $user->save(); $users = User::getAll(); echo '<h3>All Users</h3>'; prettyPrint($users); // Edit an existing user $user = User::find(1000);