Compare commits

...

10 Commits

Author SHA1 Message Date
Sadeeq Aliyu
8ad13861f3 Merge 2f1e798f54 into 559d03ecf3 2024-02-27 17:12:24 +08:00
Julien Le Coupanec
559d03ecf3 Merge pull request #372 from cunnellp5/cunnellp/vscode/add-command-and-cleanup-spaces
updates vscode cheat sheet
2024-02-26 18:25:32 +01:00
cunnellp5
bea751612a updates vscode cheat sheet with one command 2024-02-15 07:10:18 -07:00
Julien Le Coupanec
d143c60246 Merge pull request #354 from RomjanHossain/patch-1
swap current line with previous
2023-12-29 15:35:14 +01:00
Romjan D. Hossain
44371217a9 swap current line with previous
it should be `ddkP` instead of `ddkp`
2023-12-24 11:53:04 +06:00
Julien Le Coupanec
d63d75bb28 Merge pull request #350 from adgan11/patch-1
Fix Issue #316: keygen deprecated
2023-11-07 11:40:11 +01:00
Ahmed Gagan
94087440e5 Fix Issue #316: keygen deprecated 2023-11-06 12:16:17 +05:30
Bgumel
2f1e798f54 PDO class
PDO class to connect  and query database faster
2018-09-28 16:25:31 +02:00
Bgumel
d0f3d05919 new list (cheet class) added 2018-09-28 16:21:04 +02:00
Bgumel
bef420a611 PDO cheat class 2018-09-28 16:20:22 +02:00
5 changed files with 101 additions and 5 deletions

View File

@@ -95,6 +95,14 @@ Feel free to take a look. You might learn new things. They have been designed to
- [Redis](databases/redis.sh)
</details>
#### Cheat Class
<details>
<summary>view cheatsheets</summary>
- [PDO](cheatclass/PDO.php)
</details>
### 🔧 Tools
<details>

88
cheatclass/PDO.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
/*
* PDO DATABASE CLASS
* Connects Database Using PDO
* Creates Prepeared Statements
* Binds params to values
* Returns rows and results
* credit: Traversy media
*/
class Database {
private $host = "localhost";
private $user = "DB_User";
private $pass = "DB_PASS";
private $dbname = "DB_NAME";
private $dbh;
private $error;
private $stmt;
public function __construct() {
// Set DSN
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
$options = array (
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
// Create a new PDO instanace
try {
$this->dbh = new PDO ($dsn, $this->user, $this->pass, $options);
} // Catch any errors
catch ( PDOException $e ) {
$this->error = $e->getMessage();
}
}
// Prepare statement with query
public function query($query) {
$this->stmt = $this->dbh->prepare($query);
}
// Bind values
public function bind($param, $value, $type = null) {
if (is_null ($type)) {
switch (true) {
case is_int ($value) :
$type = PDO::PARAM_INT;
break;
case is_bool ($value) :
$type = PDO::PARAM_BOOL;
break;
case is_null ($value) :
$type = PDO::PARAM_NULL;
break;
default :
$type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($param, $value, $type);
}
// Execute the prepared statement
public function execute(){
return $this->stmt->execute();
}
// Get result set as Associative array
public function resultset(){
$this->execute();
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Get single record as object
public function single(){
$this->execute();
return $this->stmt->fetch(PDO::FETCH_OBJ);
}
// Get record row count
public function rowCount(){
return $this->stmt->rowCount();
}
// Returns the last inserted ID
public function lastInsertId(){
return $this->dbh->lastInsertId();
}
}

View File

@@ -185,7 +185,6 @@ width="" <!-- Describes the width of th
<!-- Some other useful tags -->
<canvas></canvas> <!-- Allows to draw 2D shapes on the web page with the help of javascript -->
<keygen> <!-- Represents a control for generating a public-private key pair -->
<map></map> <!-- Specifies an image map -->
<!-- Collective Character Obejcts -->

View File

@@ -105,7 +105,7 @@ gu$ make lowercase until end of line
<< indent line one column to left
== auto-indent current line
ddp swap current line with next
ddkp swap current line with previous
ddkP swap current line with previous
:%retab fix spaces / tabs issues in whole file
:r [name] insert the file [name] below the cursor.
:r !{cmd} execute {cmd} and insert its standard output below the cursor.

View File

@@ -6,7 +6,8 @@
#### General
- `Ctrl`+`Shift`+`P`, `F1`: Show Command Palette
- `Ctrl`+`Shift`+`P`, `F1`: Show Command Palette
- `Ctrl`+`Shift`+`T`: Open last closed tab
- `Ctrl`+`P`: Quick Open, Go to File
- `Ctrl`+`Shift`+`N`: New window/instance
- `Ctrl`+`W`: Close window/instance