本文整理汇总了PHP中CRUD类的典型用法代码示例。如果您正苦于以下问题:PHP CRUD类的具体用法?PHP CRUD怎么用?PHP CRUD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRUD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detail
public static function detail($orm, $id, $fields, $writable = true, $relations = null, $relations_limit = 10)
{
// 'main' will refer to main object, and 'rel' to its relations
$main_crud = new CRUD($orm, $fields);
$main_crud->filter(array('id' => array('=', $id)));
$_SESSION['CRUDPage']['crud'][$main_crud->getHash()] = $main_crud;
$main = array('hash' => $main_crud->getHash(), 'data' => $main_crud->getSingleRowWithTitles(), 'widgeted_data' => $main_crud->getWidgets($main_crud->getSingleRawRow()), 'id' => $id, 'writable' => $writable);
// Relations
$rels = array();
if ($relations) {
$main_model = $main_crud->getOrmClone()->find_one();
$main_model_name = $main_crud->getModelName();
foreach ($relations as $relator_mtd => $settings) {
list($fields, $details_url, $add_new, $defaults, $limit) = array_merge($settings, array(null, null, null, null));
// set default values
if (is_null($add_new)) {
$add_new = true;
}
if (is_null($defaults)) {
$defaults = array();
}
$crud = new CRUD($main_model->{$relator_mtd}(), $fields);
$crud->limit($relations_limit);
// set defaults
$rel_details = CRUD::parseRelationDetails($relator_mtd . '.', $main_model_name);
$key_name = $rel_details['key1'];
$crud->setDefaults(array_merge($defaults, array($key_name => $id)));
$_SESSION['CRUDPage']['crud'][$crud->getHash()] = $crud;
$rels[$relator_mtd] = array('hash' => $crud->getHash(), 'titles' => $crud->getTitles(), 'widgets' => $crud->getWidgets(), 'limit' => $crud->getLimit(), 'page_count' => $crud->getPageCount(), 'rel_title' => ucwords(str_replace('_', ' ', $relator_mtd)), 'add_new' => $add_new, 'details_url' => $details_url);
}
}
return json_encode(array('page_type' => 'detail', 'main' => $main, 'rels' => $rels));
}
示例2: getInstance
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new CRUD();
}
return self::$_instance;
}
示例3: auto
public static function auto($tb_name, $langtag, $id, $sort = 1)
{
$rsnum = CRUD::dataFetch($tb_name, array('id' => $id));
if (empty($rsnum)) {
return false;
}
list($selfRow) = CRUD::$data;
$addon = '';
if (isset($selfRow["parent"])) {
$addon .= !empty($selfRow["parent"]) ? " and parent = '{$selfRow["parent"]}'" : " and parent IS NULL";
}
if (!empty($selfRow['lang_id']) && !empty($selfRow['langtag'])) {
$addon .= " and langtag = '{$langtag}'";
}
$rsnum = CRUD::dataFetch($tb_name, array('custom' => "id != '{$id}' {$addon}"), false, array('sort' => CORE::$cfg["sort"]));
if (!empty($rsnum)) {
$dataRow = CRUD::$data;
foreach ($dataRow as $key => $row) {
# 讓出預定排序位置
$autoSort = ++$i == $sort ? ++$i : $i;
$sort_args[] = array('id' => $row["id"], 'sort' => $autoSort);
}
}
$sort_args[] = array('id' => $id, 'sort' => $sort);
# 重置所有相關資料排序
if (is_array($sort_args)) {
foreach ($sort_args as $args) {
DB::update(CORE::$prefix . "_" . $tb_name, array('sort' => $args["sort"], 'id' => $args["id"]));
}
}
}
示例4: check
static function check($dataTrack = array())
{
$db = new CRUD();
if (empty($dataTrack) || !array_key_exists('id_user', $dataTrack) || !array_key_exists('title', $dataTrack) || !array_key_exists('uri_module', $dataTrack) || !array_key_exists('id_content', $dataTrack) || !array_key_exists('action', $dataTrack)) {
return false;
}
$dataTrack['id_session'] = session_id();
$dataTrack['ip_user'] = $_SERVER['REMOTE_ADDR'];
$dataTrack['url_page'] = $_SERVER['REQUEST_URI'];
$dataTrack['url_referer'] = $_SERVER['HTTP_REFERER'];
$dataTrack['date'] = time();
if ($db->dbQI($dataTrack, '_users_track')) {
return true;
}
return false;
}
示例5: getInstance
public static function getInstance($conexao)
{
if (!isset(self::$crud)) {
self::$crud = new CRUD($conexao);
}
return self::$crud;
}
示例6: doMobileIndex
public function doMobileIndex()
{
global $_GPC, $_W;
$fid = $_GPC['fid'];
$fool = CRUD::findById(CRUD::$table_fool, $fid);
include $this->template("index");
}
示例7: row
public static function row()
{
$args = !self::$cate ? array('status' => '1') : array('status' => '1', 'id' => self::$cate);
$rsnum = CRUD::dataFetch('ad_cate', $args);
if (!empty($rsnum)) {
$dataRow = CRUD::$data;
$nowDate = date("Y-m-d");
foreach ($dataRow as $key => $cate) {
$rsnum = CRUD::dataFetch('ad', array('langtag' => CORE::$langtag, 'parent' => $cate["id"], 'custom' => "status = '1' or (status = '2' and startdate <= '{$nowDate}' and limitdate >= '{$nowDate}')"));
if (!empty($rsnum)) {
VIEW::newBlock("TAG_AD_BLOCK" . $cate["id"]);
foreach (CRUD::$data as $key => $row) {
VIEW::newBlock("TAG_AD_LIST" . $cate["id"]);
foreach ($row as $field => $var) {
switch ($field) {
case "link":
if (empty($var)) {
$var = '#';
}
default:
VIEW::assign("VALUE_" . strtoupper($field), $var);
break;
}
}
IMAGES::load('ad', $row["id"]);
list($images) = IMAGES::$data;
VIEW::assign(array("VALUE_IMAGE" => $images["path"], "VALUE_ALT" => $images["alt"], "VALUE_TITLE" => $images["title"]));
}
}
}
}
}
示例8: subjectFetch
protected static function subjectFetch($id, $field = '*')
{
$rsnum = CRUD::dataFetch('contact_subject', array('id' => $id), array($field));
if (!empty($rsnum)) {
list($row) = CRUD::$data;
return $row[$field];
}
return false;
}
示例9: ruleDeleted
public function ruleDeleted($rid)
{
$sin = CRUD::findUnique(CRUD::$table_sign, array(":rid" => $rid));
pdo_delete(CRUD::$table_sign_award, array("sid" => $sin['id']));
pdo_delete(CRUD::$table_sign_user, array("sid" => $sin['id']));
pdo_delete(CRUD::$table_sign_serial, array("sid" => $sin['id']));
pdo_delete(CRUD::$table_sign_record, array("sid" => $sin['id']));
pdo_delete(CRUD::$table_sign, array('rid' => $rid));
}
示例10: fetch
public static function fetch($id)
{
$rsnum = CRUD::dataFetch('stock_bind', array('id' => $id));
if (!empty($rsnum)) {
return CRUD::$data[0];
} else {
return false;
}
}
示例11: myCRUD
/**
* @return CRUD
*/
public function myCRUD()
{
if ($this->crud == null) {
$ref = new ReflectionClass($this->object);
$this->crud = Singleton::getInstance("CRUD", $ref->getName(), $ref->getName());
//$this->crud = new CRUD($ref->getName());
$this->crud->addNoIndexAtribute("dao");
}
return $this->crud;
}
示例12: news
private static function news()
{
self::$rsnum[] = $rsnum = CRUD::dataFetch('news', array('langtag' => CORE::$langtag, 'status' => '1', 'custom' => "(subject like '%" . self::$kw . "%' or content like '%" . self::$kw . "%')"));
if (!empty($rsnum)) {
$dataRow = CRUD::$data;
foreach ($dataRow as $key => $row) {
VIEW::newBlock("TAG_SEARCH_LIST");
VIEW::assign(array("VALUE_SUBJECT" => $row["subject"], "VALUE_CONTENT" => mb_substr(strip_tags($row["content"]), 0, 50, 'UTF-8'), "VALUE_LINK" => NEWS::dataLink($row["parent"], $row)));
}
}
}
示例13: nav
private static function nav()
{
VIEW::assignGlobal("NAV_CATE_TITLE", 'ABOUT');
$rsnum = CRUD::dataFetch('intro', array('status' => '1', 'langtag' => CORE::$langtag), false, array('sort' => CORE::$cfg["sort"]));
if (!empty($rsnum)) {
$dataRow = CRUD::$data;
foreach ($dataRow as $key => $row) {
VIEW::newBlock("TAG_NAV_LIST");
VIEW::assign(array("VALUE_NAV_SUBJECT" => $row["subject"], "VALUE_NAV_LINK" => CORE::$root . 'intro/' . SEO::link($row) . '/', "VALUE_NAV_CURRENT" => empty(self::$id) && ++$i == 1 || self::$id == $row["id"] ? 'active' : ''));
}
}
}
示例14: __construct
public function __construct($id_Website, $controllerName = "index", $langue = 'fr', $zoneArea = 'bigadmin', $user = array())
{
$this->timeExecution = microtime(true);
$this->langueZone = $langue;
$this->zoneArea = $zoneArea;
$this->controllerNameNow = $controllerName;
$this->user = $user;
if (empty($langue)) {
$db = new CRUD();
$isWebsite = $db->dbQS($id_Website, '_website');
if (!empty($isWebsite)) {
$langue = $isWebsite['langue_front'];
$isWebsite['langue_groupe'] = unserialize($isWebsite['langue_groupe']);
$isWebsite['langue_groupe'][$langue] = $langue;
$urlToRedirect = URL_USER . $langue . '/';
$cLangues = count($isWebsite['langue_groupe']);
if ($cLangues === 1) {
$urlToRedirect = URL;
}
if ($cLangues > 1) {
header('HTTP/1.1 301 Moved Permanently', false, 301);
header('Location: ' . $urlToRedirect);
exit;
}
}
}
if (!empty($this->user) && $zoneArea === 'user' && $_SESSION['doorgets_user']['langue'] !== $langue && $controllerName !== 'changelangue') {
header('Location: ' . URL_USER . $_SESSION['doorgets_user']['langue'] . '/');
exit;
}
parent::__construct($langue);
if (!empty($this->user) && !empty($this->user['timezone'])) {
date_default_timezone_set($this->user['timezone']);
}
$this->getParams();
$this->getController();
$this->reloadController();
$this->isRtlLanguage = in_array($this->myLanguage, Constant::$rtlLanguage) ? true : false;
}
示例15: obtain
public static function obtain()
{
if (!self::$instance) {
self::$instance = new crud();
}
return self::$instance;
}