public static function help($mode = 0)
 {
     $conn = Db::getInstance();
     $conts = $conn->fetchAll("SELECT * FROM category");
     $datas = [];
     switch ($mode) {
         case 0:
             foreach ($conts as $cont) {
                 $datas[] = [$cont['id'] => $cont['name']];
             }
             return $datas;
         case 1:
             foreach ($conts as $cont) {
                 $datas[] = $cont['slug'];
             }
             return $datas;
         case 2:
             return $conts;
     }
 }
 public static function help()
 {
     $conn = Db::getInstance();
     $count = $conn->fetchAll("SELECT * FROM approvedBooksRequest");
     return count($count);
 }
 public static function help()
 {
     $conn = Db::getInstance();
     $conts = $conn->fetchAll("SELECT * FROM lateBooks");
     return count($conts);
 }
Пример #4
0
 */
$app->register(new \Silex\Provider\DoctrineServiceProvider());
$app->register(new \Silex\Provider\TwigServiceProvider(), ['twig.path' => [__DIR__ . '/../src/Templates', __DIR__ . '/../vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/Resources/views'], 'twig.options' => ['cache' => __DIR__ . '/../app/cache/app_template', 'auto_reload' => true]]);
$app->register(new Dezull\Silex\Provider\DBALPaginatorServiceProvider\DBALPaginatorServiceProvider(), ['dezull.dbal_paginator.template.pagination' => 'Pagination/twitter_bootstrap_pagination.html.twig', 'dezull.dbal_paginator.template.sortable' => 'Pagination/sortable_link.html.twig']);
$app->register(new \Silex\Provider\FormServiceProvider());
$app->register(new \Silex\Provider\SessionServiceProvider());
$app->register(new \Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new \Silex\Provider\ServiceControllerServiceProvider());
$app->register(new \Silex\Provider\HttpFragmentServiceProvider());
$app->register(new \Silex\Provider\ValidatorServiceProvider());
$app->register(new \Silex\Provider\MonologServiceProvider(), ['monolog.logfile' => __DIR__ . '/../app/logs/development.log']);
$app->register(new \Silex\Provider\TranslationServiceProvider());
$app->mount('/', new \ExpressLibrary\Controllers\Front($app));
$app->mount('/admin', new \ExpressLibrary\Controllers\Back($app));
$app['db'] = function () {
    return \ExpressLibrary\Db\Db::getInstance();
};
$app['slugify'] = function () {
    return new Cocur\Slugify\Slugify();
};
$app['fs'] = function () {
    return new Symfony\Component\Filesystem\Filesystem();
};
if ($app['debug']) {
    Symfony\Component\Debug\Debug::enable(E_ALL, true);
    $app->register(new Silex\Provider\WebProfilerServiceProvider(), ['profiler.cache_dir' => __DIR__ . '/../app/cache/profiler']);
}
$app->error(function (\Exception $e, $code) {
    switch ($code) {
        case 404:
            $message = 'The requested page could not be found.';
 public function __construct()
 {
     $this->db = Db::getInstance();
 }
<?php

/*
 * script ini berfungsi untuk
 *
 *
 */
include "../vendor/autoload.php";
use ExpressLibrary\Db\Db;
$conn = Db::getInstance();
$allId = $conn->fetchAll("SELECT voteForBookId FROM vote");
$filteredId = [];
for ($i = 0; $i < count($allId); $i++) {
    echo $i . "\n";
    $filteredId[] = $allId[$i]["voteForBookId"];
}
$resArray = array_unique($filteredId);
$secondFilteredId = array_values($resArray);
$sql = "TRUNCATE TABLE  voteResult";
$stmt = $conn->prepare($sql);
$stmt->execute();
for ($ii = 0; $ii < count($secondFilteredId); $ii++) {
    $likeData = $conn->fetchAll("SELECT id FROM vote WHERE voteForBookId = ? AND voteValue = ?", [$secondFilteredId[$ii], 'like']);
    $unLikeData = $conn->fetchAll("SELECT id FROM vote WHERE voteForBookId = ? AND voteValue = ?", [$secondFilteredId[$ii], 'unlike']);
    if ($likeData) {
        $conn->insert('voteResult', ['bookId' => (int) $secondFilteredId[$ii], 'value' => "like", 'result' => count($likeData)]);
    } else {
        $conn->insert('voteResult', ['bookId' => (int) $secondFilteredId[$ii], 'value' => "like", 'result' => 0]);
    }
    if ($unLikeData) {
        $conn->insert('voteResult', ['bookId' => (int) $secondFilteredId[$ii], 'value' => "unlike", 'result' => count($unLikeData)]);
 public static function help()
 {
     $conn = Db::getInstance();
     $conts = $conn->fetchAll("SELECT * FROM borrowRequest");
     return count($conts);
 }