1. Go to this page and download the library: Download pejman/peji 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/ */
pejman / peji example snippets
use Peji\DB\DB as DB;
use Peji\Config as Config;
use Peji\View as View;
Config::setDir('../config');
$dbConf = Config::file('db');
define('siteUrl', $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'] );
DB::init( $dbConf['host'], $dbConf['username'], $dbConf['password'], $dbConf['db'] );
DB::setAttr([
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'" ,
\PDO::ATTR_PERSISTENT => false ,
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true ,
]);
View::setDir( '../app/View' );
try {
namespace App\Model;
class Posts extends \Peji\DB\Model {
var $table = 'posts';
function getComments() {
return Comments::sql("where postid = ? ")->find([ $this->id ]);
}
}
use App\Model\Posts;
$posts = Posts::sql("order by id desc")->paginate(10, @$this->get['page']?:1)->find();
foreach( $posts as $post ) {
print_r( $post->comments );
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.