PHP code example of phpset / pdomodel
1. Go to this page and download the library: Download phpset/pdomodel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpset / pdomodel example snippets
class YoutubeVideosModel extends \PdoModel\PdoModel
{
const TABLE = 'youtube_videos';
protected function create($title, $src) {
$this->insert(['title' => $title, 'src' => $src]);
}
}
$youtubeVideosModel = new YoutubeVideosModel(new \Pdo());
$result = $youtubeVideosModel->select(['id', 'likes', 'url'])
->whereEqual('published', 1)
->where('likes', '>', 100)
->orderBy('likes desc')
->limit(100)
->offset(2000)
->groupBy('author')
->getAllRows();
var_dump($result);
$connection = new \PDO(
"mysql:host=127.0.0.1;dbname=YOURDBNAME;charset=utf8mb4",
"YOURUSER",
"YOURPASSWORD",
[
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
]
);
$connection = new \PDO('sqlite::db.sqlite');
new PdoModel($connection)->setTable('test_table');
yaml
PDO:
class: \PDO
arguments:
- "mysql:host=127.0.0.1;dbname=YOURDBNAME;charset=utf8mb4"
- "YOURUSER"
- "YOURPASSWORD"
-
!php/const PDO::ATTR_DEFAULT_FETCH_MODE: !php/const PDO::FETCH_ASSOC
!php/const PDO::ATTR_ERRMODE: !php/const PDO::ERRMODE_EXCEPTION