本文整理汇总了PHP中CRUD类的典型用法代码示例。如果您正苦于以下问题:PHP CRUD类的具体用法?PHP CRUD怎么用?PHP CRUD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRUD类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:cal127,项目名称:phpcrud,代码行数:33,代码来源:Page.php
示例2: getInstance
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new CRUD();
}
return self::$_instance;
}
开发者ID:kirannaikdanavath,项目名称:fanci,代码行数:7,代码来源:dbconnect.class.php
示例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"]));
}
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:31,代码来源:sort.php
示例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;
}
开发者ID:neoartdoo,项目名称:CMS,代码行数:16,代码来源:UsersTracking.php
示例5: getInstance
public static function getInstance($conexao)
{
if (!isset(self::$crud)) {
self::$crud = new CRUD($conexao);
}
return self::$crud;
}
开发者ID:guimenegussi,项目名称:PHP-PDO-OO,代码行数:7,代码来源:crud.class.php
示例6: doMobileIndex
public function doMobileIndex()
{
global $_GPC, $_W;
$fid = $_GPC['fid'];
$fool = CRUD::findById(CRUD::$table_fool, $fid);
include $this->template("index");
}
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:7,代码来源:site.php
示例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"]));
}
}
}
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:32,代码来源:frontend.php
示例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;
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:9,代码来源:index.php
示例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));
}
开发者ID:ChainBoy,项目名称:wxfx,代码行数:9,代码来源:module.php
示例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;
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:9,代码来源:index.php
示例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;
}
开发者ID:laiello,项目名称:samusframework,代码行数:13,代码来源:DAO_CRUD.php
示例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)));
}
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:11,代码来源:index.php
示例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' : ''));
}
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:12,代码来源:frontend.php
示例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;
}
开发者ID:neoartdoo,项目名称:CMS,代码行数:39,代码来源:doorGetsUser.php
示例15: delete
private static function delete($id)
{
$rs = CRUD::dataDel('feedback', array('id' => $id));
if (!empty(DB::$error)) {
$msg = DB::$error;
$path = CORE::$manage . 'feedback/';
}
if (!$rs) {
$msg = self::$lang["del_error"];
$path = CORE::$manage . 'feedback/';
} else {
$msg = self::$lang["del_done"];
$path = CORE::$manage . 'feedback/';
}
CORE::msg($msg, $path);
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:16,代码来源:backend.php
示例16: init
/**
* Inicia a anlise de um objeto
* @return void
*/
public function init()
{
$ref = new ReflectionClass($this->object);
$parentClassesArray = array($ref);
while ($ref->getParentClass()->getName() != CRUD::getTopLevelClass()) {
$ref = $ref->getParentClass();
$parentClassesArray[] = $ref;
}
$parentClassesArray = array_reverse($parentClassesArray);
foreach ($parentClassesArray as $ref) {
/*@var $ref ReflectionClass */
foreach ($ref->getProperties() as $prop) {
/* @var $prop ReflectionProperty */
$this->readDocComment($prop);
}
}
$this->initCheck = true;
}
开发者ID:laiello,项目名称:samusframework,代码行数:22,代码来源:RequestValidator.php
示例17: view
public static function view($tablename, $item, $fields_header, $options = array())
{
$view = new View("_crud/detail");
$view->title = "Dettaglio Cliente";
$view->tableName = $tablename;
$view->link_add = CRUD::getLink("cliente", "add");
$view->link_edit = CRUD::getLink("cliente", "edit");
$view->fields_header = $fields_header;
$view->row = $item;
// tutte le componenti di options
// diventano variabili della vista
if (is_array($options) && count($options) > 0) {
foreach ($options as $key => $value) {
$view->{$key} = $value;
}
}
// mostro la view di crud
$view->render();
}
开发者ID:sg4r3z,项目名称:umvc,代码行数:19,代码来源:class.crud.php
示例18: executeQuery
/**
* Executa uma query conforme o modo selecionado
* @param string $sql
* @return PDO|resource
*/
public static function executeQuery($sql)
{
if (self::$modo == self::QUERY_MODE_PDO) {
$r1 = self::getConn()->query($sql);
$error = CRUD::getPDO()->errorInfo();
if (isset($error[1])) {
if ($error[1] != null) {
throw new CRUDQueryException("CRUD SQL ERROR - {$sql} <hr />ERROR INFO:" . $error[2]);
}
}
return $r1;
} elseif (self::$modo == self::QUERY_MODE_MYSQLI) {
$r1 = mysqli_query(self::getConn(), $sql);
if (mysqli_errno(self::getConn()) != 0) {
throw new CRUDQueryException("CRUD SQL ERROR - {$sql} <hr />ERROR INFO:" . mysqli_errno(ConnectionMySqli::getConn()));
}
return $r1;
}
}
开发者ID:laiello,项目名称:samusframework,代码行数:24,代码来源:CRUDQuery.php
示例19: idx_row
public static function idx_row()
{
$rsnum = CRUD::dataFetch('news', array('status' => '1', 'langtag' => CORE::$langtag), false, array('sort' => CORE::$cfg["sort"]), '0,4');
if (!empty($rsnum)) {
foreach (CRUD::$data as $key => $row) {
VIEW::newBlock("IDX_NEWS_LIST");
foreach ($row as $field => $var) {
switch ($field) {
case "showdate":
VIEW::assign("VALUE_" . strtoupper($field), date("Y.m.d", strtotime($var)));
break;
default:
VIEW::assign("VALUE_" . strtoupper($field), $var);
break;
}
}
VIEW::assign("VALUE_LINK", self::dataLink($row["parent"], $row));
}
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:20,代码来源:index.php
示例20: setting
public static function setting()
{
$rsnum = CRUD::dataFetch('system', array('id' => '1'));
if (!empty($rsnum)) {
self::$setting = CRUD::$data[0];
foreach (self::$setting as $field => $var) {
switch ($field) {
case "address":
if (!empty($var)) {
$output['SYSTEM_MAP'] = 'https://maps.google.com.tw/maps?f=q&hl=zh-TW&geocode&q=' . $var;
}
break;
case "ga":
$var = self::gaLoad($var);
break;
case "email":
if (empty($var)) {
# 如果未設定系統 E-mail,設定初始 E-mail
$var = '[email protected]';
self::$setting[$field] = $var;
}
break;
case "facebook":
case "gplus":
case "twitter":
case "instagram":
case "linkedin":
$output['SYSTEM_' . strtoupper($field) . '_TARGET'] = !empty($var) ? '_blank' : '_self';
$var = empty($var) ? '#' : $var;
break;
}
$output['SYSTEM_' . strtoupper($field)] = $var;
}
VIEW::assignGlobal($output);
}
}
开发者ID:PotsonHumer,项目名称:OGS_V2,代码行数:36,代码来源:index.php
注:本文中的CRUD类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论