当前位置: 首页>>代码示例>>PHP>>正文


PHP ORM::forTable方法代码示例

本文整理汇总了PHP中ORM::forTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::forTable方法的具体用法?PHP ORM::forTable怎么用?PHP ORM::forTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ORM的用法示例。


在下文中一共展示了ORM::forTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nettoyerBase

 private final function nettoyerBase()
 {
     return (bool) ORM::forTable(self::NOM_TABLE)->whereRaw('(NOW() - `date_activite`) >= ?', array(Config::DUREE_SESSION))->deleteMany();
 }
开发者ID:RedaB,项目名称:PHPBase,代码行数:4,代码来源:GestionnaireSession.class.php

示例2: json_decode

    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $programExercise = ORM::for_table('program_exercises')->create();
    $programExercise->program_id = $programId;
    $programExercise->exercise_id = $requestParams->exercise_id;
    $programExercise->order_number = $requestParams->order_number;
    $programExercise->save();
    echo json_encode(["program_exercise_id" => $programExercise->id()]);
});
/**
 * Update a program exercise
 */
$app->put('/programs/:program_id/exercises/:program_exercise_id', function ($programId, $programExerciseId) use($app) {
    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $programExercise = ORM::for_table('program_exercises')->find_one($programExerciseId);
    $programExercise->program_id = $programId;
    $programExercise->exercise_id = $requestParams->exercise_id;
    $programExercise->order_number = $requestParams->order_number;
    $programExercise->save();
    $programExercise = ORM::for_table('program_exercises')->find_one($programExerciseId)->as_array();
    echo json_encode($programExercise);
});
/**
 * Delete a program exercise id.
 */
$app->delete('/programs/:program_id/exercises/:program_exercise_id', function ($programId, $programExerciseId) use($app) {
    $programExercise = ORM::forTable('program_exercises')->findOne($programExerciseId);
    $programExercise->delete();
    $app->response()->setStatus(200);
});
开发者ID:ville6000,项目名称:WorkoutTracker-API,代码行数:31,代码来源:programsexercises.php

示例3: obtenirTout

 public static function obtenirTout(Condition $conditions = NULL, $offset = 0, $limite = NULL)
 {
     $listeRecords = ORM::forTable(self::nomTable());
     // Prise en compte d'éventuelles conditions
     if ($conditions !== NULL) {
         $listeRecords->whereRaw($conditions->generer(), $conditions->listeValeurs());
     }
     // Pris en compte de l'éventuel limite
     if ($limite !== NULL) {
         $listeRecords->limit($limite);
     }
     // Prise en compte de l'éventuel offset
     $listeRecords->offset($offset);
     // Récupération des résultats
     $listeRecords = $listeRecords->findMany();
     $listeElements = array();
     // On récupère le nom de la classe instanciée pour pouvoir en retourner les objets
     $nomClasse = get_called_class();
     foreach ($listeRecords as $record) {
         $objet = new $nomClasse();
         // Hydration de l'objet
         $objet->setRecord($record);
         // Ajout dans la liste des résultats
         $listeElements[] = $objet;
     }
     return $listeElements;
 }
开发者ID:RedaB,项目名称:PHPBase,代码行数:27,代码来源:ModeleBase.class.php

示例4: i_get

 function i_get()
 {
     require 'idiorm/idiorm.php';
     require 'application/config/idiorm.php';
     $data = new stdClass();
     $data->songs = ORM::forTable('songs')->whereRaw('(`time` > ? AND `time` < ?)', array(0, 32))->orderByAsc('artist')->findResultSet();
     return $data;
 }
开发者ID:NaszvadiG,项目名称:cim-xa,代码行数:8,代码来源:songs.php

示例5: call

 public function call()
 {
     $app = $this->app;
     if (isset($_SESSION['uid'])) {
         $env = $app->environment();
         $env['user'] = ORM::forTable('users')->findOne($_SESSION['uid']);
         $this->next->call();
     } else {
         $app->redirect(SITE_URL . '/login');
     }
 }
开发者ID:xintao222,项目名称:livehub,代码行数:11,代码来源:console.php

示例6: call

 public function call()
 {
     $app = $this->app;
     $env = $app->environment();
     if (isset($_SESSION['uid'])) {
         $user = ORM::forTable('users')->findOne($_SESSION['uid']);
         $endpoint = array('id' => $_SESSION['username'], 'nick' => $user->nick, 'presence' => 'online', 'show' => 'available', 'status' => $user->status, 'url' => '#', 'pic_url' => Gravatar::url($user->login), 'role' => 'user');
         $env['endpoint'] = $endpoint;
     }
     $this->next->call();
 }
开发者ID:xintao222,项目名称:livehub,代码行数:11,代码来源:webim.php

示例7: function

});
/**
 * PUT request for workout
 */
$app->put('/workouts/:workout_id', function ($workoutId) use($app) {
    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $workout = ORM::forTable('workout')->findOne($workoutId);
    $workout->user_id = 0;
    $workout->program_id = $requestParams->program_id;
    $workout->date = $requestParams->date;
    $workout->user_weight = $requestParams->user_weight;
    $workout->user_rhr = $requestParams->user_rhr;
    $workout->start_time = $requestParams->start_time;
    $workout->end_time = $requestParams->end_time;
    $workout->comments = $requestParams->comments;
    if (!$workout->save()) {
        $app->response()->setStatus(500);
    } else {
        echo json_encode(["workout_id" => $workoutId]);
    }
});
/**
 * DELETE request for workout
 */
$app->delete('/workouts/:workout_id', function ($workoutId) use($app) {
    $program = ORM::forTable('workout')->findOne($workoutId);
    if (!$program->delete()) {
        $app->response()->setStatus(500);
    }
});
开发者ID:ville6000,项目名称:WorkoutTracker-API,代码行数:31,代码来源:workouts.php

示例8: function

    if ($workoutExercise->save()) {
        $app->response->body(json_encode(["workout_exercise_id" => $workoutExercise->workout_exercise_id]));
    } else {
        $app->response()->setStatus(500);
    }
});
/**
 * PUT request for workout exercise
 */
$app->put('/workouts/:workout_id/exercises/:workout_exercise_id', function ($workoutId, $workoutExerciseId) use($app) {
    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $workoutExercise = ORM::forTable('workout_exercises')->findOne($workoutExerciseId);
    $workoutExercise->workout_id = $workoutId;
    $workoutExercise->exercise_id = $requestParams->exercise_id;
    $workoutExercise->instructions = $requestParams->instructions;
    $workoutExercise->comment = $requestParams->comment;
    $workoutExercise->order_number = $requestParams->order_number;
    if (!$workoutExercise->save()) {
        $app->response()->setStatus(500);
    }
});
/**
 * DELETE request for workout exercise
 */
$app->delete('/workouts/:workout_id/exercises/:workout_exercise_id', function ($workoutId, $workoutExerciseId) use($app) {
    $workoutExercise = ORM::forTable('workout_exercises')->findOne($workoutExerciseId);
    if (!$workoutExercise->delete()) {
        $app->response()->setStatus(500);
    }
});
开发者ID:ville6000,项目名称:WorkoutTracker-API,代码行数:31,代码来源:workoutsexercises.php

示例9: testClearingInvalidCache

 public function testClearingInvalidCache()
 {
     $this->setExpectedException('Exception');
     Orm::configure('caching', true);
     Orm::configure('caching_driver', 'invalid');
     try {
         ORM::forTable('widget')->where('name', 'Fred')->where('age', 17)->findOne();
     } catch (Exception $e) {
         Orm::clearCache();
     }
 }
开发者ID:kevinsperrine,项目名称:idiorm,代码行数:11,代码来源:IdiormSQLiteTest.php

示例10: adminOnly

<?php

adminOnly();
if ($_POST) {
    $id = (int) $_POST['id'];
    $description = trim($_POST['description']);
    $image = isset($_POST['image']) ? filter_var(trim($_POST['image']), FILTER_VALIDATE_URL) : '';
    if (!($perle = ORM::forTable('perles_posts')->findOne($id))) {
        $_SESSION['message'] = 'Pērle netika atrasta.';
    } elseif (!getimagesize($image)) {
        $_SESSION['message'] = 'Tas nav attēls.';
    } else {
        /**
         * Gotta delete the image from assets folder
         * if it exists there (basically has been uploaded)
         */
        deleteUploadedImage(basename($perle->image));
        $perle->description = $description;
        $perle->image = protocolRelativeUrl($image);
        $perle->save();
        $_SESSION['message'] = 'Pērle saglabata.';
    }
    if (isset($_POST['ref']) && !empty($_POST['ref'])) {
        redirect(urldecode($_POST['ref']));
    }
}
redirect($config['url']);
开发者ID:arnoldsk,项目名称:Exs-Perles,代码行数:27,代码来源:update.php

示例11: verify

 /**
  * Check passed auth token
  *
  * @param string $authToken
  * @return boolean
  */
 protected function verify($authToken)
 {
     $user = \ORM::forTable('users')->where('apikey', $authToken)->findOne();
     if (false !== $user) {
         $this->app->user = $user->asArray();
         return true;
     }
     return false;
 }
开发者ID:andrejuseu,项目名称:REST,代码行数:15,代码来源:TokenOverBasicAuth.php

示例12: header

        die;
    }
} else {
    /**
     * Redirect to newest pearl to show the identifier in url (for sharing purpouses)
     */
    header('Location: ' . $config['url'] . '/' . strtotime($perle->created));
    die;
}
/**
 * Next and prev
 *
 * False if not found
 */
$prev = ORM::forTable('perles_posts')->where('active', 1)->whereRaw('`id` = (SELECT max(`id`) FROM `perles_posts` WHERE `id` < ? AND `active` = 1)', array($perle->id))->findOne();
$next = ORM::forTable('perles_posts')->where('active', 1)->whereRaw('`id` = (SELECT min(`id`) FROM `perles_posts` WHERE `id` > ? AND `active` = 1)', array($perle->id))->findOne();
// ------------------------------------------------------------------ //
require 'layout/header.php';
?>

    <?php 
if ($perle) {
    ?>
        <ul id="pager" class="pager">
            <?php 
    if ($next) {
        ?>
                <li class="previous"><a href="<?php 
        echo $config['url'];
        ?>
/<?php 
开发者ID:arnoldsk,项目名称:Exs-Perles,代码行数:31,代码来源:home.php

示例13: validaNotesContactID

 public function validaNotesContactID($note)
 {
     if (isset($note['body']) && empty($note['body'])) {
         $this->addError('notes', 'contact_id', 'contact_id cannot be empty');
     }
     $results = \ORM::forTable('notes')->where('contact_id', $note['contact_id'])->count();
     if (!$results) {
         $this->addError('notes', 'contact_id', 'contact_id dont exists');
     }
     return $this->hasErrors();
 }
开发者ID:lga37,项目名称:modelo,代码行数:11,代码来源:Application.php

示例14: function

 * POST request for programs
 */
$app->post('/programs', function () use($app) {
    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $program = ORM::forTable('programs')->create();
    // TODO: replace with real user id
    $program->user_id = 0;
    $program->name = $requestParams->name;
    $program->save();
    echo json_encode(["program_id" => $program->id()]);
});
/**
 * PUT request for programs
 * TODO Access control
 */
$app->put('/programs/:id', function ($id) use($app) {
    $requestBody = $app->request()->getBody();
    $requestParams = json_decode($requestBody);
    $program = ORM::forTable('programs')->findOne($id);
    $program->name = $requestParams->name;
    return $program->save();
});
/**
 * DELETE request for programs
 * TODO Access control
 */
$app->delete('/programs/:id', function ($id) use($app) {
    $program = ORM::forTable('programs')->findOne($id);
    return $program->delete();
});
开发者ID:ville6000,项目名称:WorkoutTracker-API,代码行数:31,代码来源:programs.php

示例15: Exception

                            return;
                        } else {
                            throw new Exception("Unable to save note");
                        }
                    } else {
                        throw new ValidationException("Invalid data", 0, $errors);
                    }
                }
            }
            $app->notFound();
        })->via('PUT', 'PATCH');
        // Delete single note
        $app->delete('/contacts/:id/notes/:note_id', function ($id, $note_id) use($app, $log) {
            $contact = \ORM::forTable('contacts')->select('id')->findOne($id);
            if ($contact) {
                $note = \ORM::forTable('notes')->findOne($note_id);
                if ($note) {
                    $note->delete();
                    $app->halt(204);
                }
            }
            $app->notFound();
        });
    });
});
// Public human readable home page
$app->get('/', function () use($app, $log) {
    echo "<h1>Hello, this can be the public App Interface</h1>";
});
// JSON friendly errors
// NOTE: debug must be false
开发者ID:lga37,项目名称:modelo,代码行数:31,代码来源:api.old.php


注:本文中的ORM::forTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。