function record($table, $id)
 {
     include_once ROOT . "app/main/record.php";
     $record = new record($this->model($table));
     $record->findById($id);
     return $record;
 }
Beispiel #2
0
<?php

require_once 'global.php';
$engine = isset($_GET['engine']) && !empty($_GET['engine']) ? $_GET['engine'] : '';
$site = isset($_GET['sitename']) && !empty($_GET['sitename']) ? $_GET['sitename'] : '';
$url = isset($_GET['url']) && !empty($_GET['url']) ? $_GET['url'] : '';
$date = isset($_GET['date']) && !empty($_GET['date']) ? $_GET['date'] : '';
if (!$engine || !$site || !$url || !$date) {
    echo 'Error!';
    exit;
}
$timestamp = strtotime($date);
$r = new record();
//当前月数据
$curr_tmp = $r->get_record_by_url($url, $date);
//上月数据
$days = date('t', $timestamp);
$prev_tmp = $r->get_record_by_url($url, date('Y-n-d', $timestamp - $days * 24 * 3600));
//月份参数
$filters = array('yr' => date('Y', $timestamp), 'mo' => date('n', $timestamp));
$curr_data = $prev_data = array();
if ($curr_tmp) {
    foreach ($curr_tmp as $key => $val) {
        $curr_data['dy'][$key] = $val;
    }
}
if ($prev_tmp) {
    foreach ($prev_tmp as $key => $val) {
        $prev_data['dy'][$key] = $val;
    }
}
Beispiel #3
0
<?php

// link to the record file
include 'record.php';
//in a live enviroment we would validate the data now.
//for the example we will skipp that
// controller passes data to the model using the create function.
$new = record::create($_POST);
?>
<pre>
<?php 
print_r($new);
?>
</pre>

Data was sent from the view and handed off to the controller and then given to the model to be saved.
 /**
  * Given a type and an id, instantiate a record
  * If no id given, instantiate a new empty record of type, using the right class for this record type
  * For instance if it is a multilingual table, it will return a multilingual record object (@todo)
  *
  **/
 function newRecord($table, $id = false, $data = false)
 {
     // will include the right module class if needed, for example, specialized modules like ftp datasource
     // currently the base module is used
     if ($table != '') {
         // optimization : file is required on top of this class file
         // optimization removed, because no real speed impact found
         // find if the record has a locale field
         $multilingual = false;
         if (isset($this->config['table'][$table]['field'])) {
             foreach ($this->config['table'][$table]['field'] as $field) {
                 if ($field['type'] == 'locale') {
                     $multilingual = true;
                 }
             }
         }
         if ($multilingual) {
             require_once 'record.multilingual.class.php';
             $record = new record_multilingual($table);
         } else {
             require_once 'record.class.php';
             $record = new record($table);
         }
         if ($id) {
             $record->set('id', $id);
         }
         if ($data) {
             $record->loadByArray($data);
         }
         return $record;
     } else {
         trigger_error('thinkedit::newRecord() $table not defined');
     }
 }
 public function __construct($result, $info)
 {
     if (is_array($result)) {
         $this->__info = $info;
         $this->__data = $result;
     } else {
         parent::__construct($result, $info);
         $this->__data = parent::getData();
     }
     unset($this->__link);
     unset($this->__result);
 }
 function load()
 {
     //this is tricky : we first try to load the record
     if (parent::load()) {
         return true;
     } else {
         // we set the locale of the record to the first found locale for this record
         $locale_list = $this->getLocaleList();
         $this->setLocale($locale_list[0]);
         return parent::load();
     }
 }
<?php

require_once '../class/url.class.php';
require_once '../class/record.class.php';
require_once '../thinkedit.init.php';
$url = new url();
$url->setParam('id', 7);
$url->setParam('action', 'move');
$url->setParam('locale', 'en');
$url->unSetParam('id');
echo '<pre>';
echo $url->render();
// try it with ./url.test.php?test_class=record&test_type=article&test_id=5
// and with url.test.php?test_class=record&test_type=article
echo $url->getParam('test');
$record = new record('article');
$record->set('id', 5);
$url->addObject($record, 'my_');
echo '<hr>';
echo $url->render();
$object = $url->getObject('test_');
$object->load();
echo '<hr>';
print_r($object);
 /**
  * Given a type and an id, instantiate a record
  * If no id given, instantiate a new empty record of type, using the right class for this record type
  * For instance if it is a multilingual table, it will return a multilingual record object (@todo)
  *
  **/
 function newRecord($table, $id = false, $data = false)
 {
     // will include the right module class if needed, for example, specialized modules like ftp datasource
     // currently the base module is used
     if ($table != '') {
         // optimization : file is required on top of this class file
         require_once 'record.class.php';
         $record = new record($table);
         if ($id) {
             $record->set('id', $id);
         }
         if ($data) {
             $record->loadByArray($data);
         }
         return $record;
     } else {
         trigger_error('thinkedit::newRecord() $table not defined');
     }
 }
Beispiel #9
0
 /**
  * Part of the cache_cacheableInterface
  *
  * @param  string        $option
  * @return caption_field
  */
 public function delete_data_from_cache($option = null)
 {
     $this->fields = null;
     return $this->record->get_databox()->delete_data_from_cache($this->get_cache_key($option));
 }
 /**
  * Associates the record object to this one
  * @return boolean
  */
 function GetRecord()
 {
     $record = new record();
     return $record->Get($this->recordId);
 }
Beispiel #11
0
 /**
  * Part of the cache_cacheableInterface
  *
  * @param  string $option
  * @return string
  */
 public function get_cache_key($option = null)
 {
     return 'caption_field_' . $this->databox_field->get_id() . '_' . $this->record->get_serialize_key() . ($option ? '_' . $option : '');
 }
Beispiel #12
0
//抓取当月平均值(2010.9.6新加的)
$file_crawl_mon = './data/crawl/' . $engine . '/' . $site . '/' . md5('all') . '/' . date('Ym', strtotime($date)) . '.txt';
//echo $file_crawl_mon;
$crawl_average = file_exists($file_crawl_mon) ? file($file_crawl_mon) : 0;
if ($crawl_average) {
    $total = 0;
    foreach ($crawl_average as $v) {
        $tmp = explode('#####', $v);
        $arr = unserialize($tmp[1]);
        $total += $arr['count'];
    }
    $crawl_average_value = number_format($total / count($crawl_average));
    //echo $crawl_average_value;
}
//收录统计
$r = new record();
$curr_record = $r->get_records_by_day($date, $engine);
$last_record = $r->get_records_by_day($prevdate, $engine);
//收录概要
$record_summary = array();
if (isset($curr_record['data']) && count($curr_record['data']) > 0) {
    $curr_rc = current($curr_record['data']);
    if ($last_record['data']) {
        $prev_rc = current($last_record['data']);
    }
    $record_summary = summary_diff($curr_rc, $prev_rc);
}
//抓取统计
$crawl = new crawl();
$curr_crawl = $crawl->get_crawls_by_date($date, $engine);
$last_crawl = $crawl->get_crawls_by_date($prevdate, $engine);
Beispiel #13
0
 public function setParent(&$parent)
 {
     self::$parent = $parent;
     $this->parent2 = $parent;
 }
 function record_multilingual($table)
 {
     parent::record($table);
 }
Beispiel #15
0
 /**
  * Gets a list of record objects associated to this one
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
  * @param string $sortBy 
  * @param boolean $ascending 
  * @param int limit 
  * @return array of record objects
  */
 function GetRecordList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $record = new record();
     $fcv_array[] = array("userId", "=", $this->userId);
     $dbObjects = $record->GetList($fcv_array, $sortBy, $ascending, $limit);
     return $dbObjects;
 }
Beispiel #16
0
     //			"header":"{\"rec...rsion\":\"0.1\"}",
     //			"statistics":"44kOOda0xYZjbcugJBdagBQx",
     //			"version":"0.3",
     //			"lock":"----"
     //		}
     //	}
     //}
     $user = new user();
     $user = $user->Get($_SESSION["userId"]);
     $recordReferenceList = $parameters["parameters"]["recordReferences"];
     $recordList = array();
     $c = count($recordReferenceList);
     for ($i = 0; $i < $c; $i++) {
         array_push($recordList, array("reference", "=", $recordReferenceList[$i]));
     }
     $record = new record();
     $record->DeleteList($recordList, true);
     updateUserData($parameters["parameters"]["user"], $user);
     $user->Save();
     $result["recordList"] = $recordList;
     $result["lock"] = $user->lock;
     $result["result"] = "done";
     //=============================================================
 } else {
     if ($message == "deleteUser") {
         //{"message":"deleteUser", "srpSharedSecret":"e8e4ca6544dca49c95b3647d8358ad54c317048b74d2ac187ac25f719c9bac58", "parameters":{}}
         $user = new user();
         $user->Get($_SESSION["userId"]);
         $user->Delete(true);
         $result["result"] = "ok";
         //=============================================================
if (!isset($table_select)) {
    $result = $dbc->prepare("show tables");
    $i = 0;
    $table = "";
    $tables = $dbc->executeGetRows($result);
    foreach ($tables as $table_array) {
        list(, $table) = each($table_array);
        $exclude_this_table = isset($table_exclude) ? in_array($table, $table_exclude) : false;
        if (!$exclude_this_table) {
            $table_select[$i] = $table;
        }
        $i++;
        //echo "$table<br>";
    }
}
$recordBackup = new record();
$thedomain = $_SERVER['HTTP_HOST'];
if (substr($thedomain, 0, 4) == "www.") {
    $thedomain = substr($thedomain, 4, strlen($thedomain));
}
$buffer = '# MySQL backup created by phpMySQLAutoBackup - Version: ' . $phpMySQLAutoBackup_version . NEWLINE . '# ' . NEWLINE . '# http://www.dwalker.co.uk/phpmysqlautobackup/' . NEWLINE . '#' . NEWLINE . '# Database: ' . $db . NEWLINE . '# Domain name: ' . $thedomain . NEWLINE . '# (c)' . date('Y') . ' ' . $thedomain . NEWLINE . '#' . NEWLINE . '# Backup START time: ' . strftime("%H:%M:%S", time()) . NEWLINE . '# Backup END time: #phpmysqlautobackup-endtime#' . NEWLINE . '# Backup Date: ' . strftime("%d %b %Y", time()) . NEWLINE;
$i = 0;
$lines_exported = 0;
$alter_tables = "";
foreach ($table_select as $table) {
    $i++;
    $export = ' ' . NEWLINE . 'drop table if exists `' . $table . '`; ' . NEWLINE;
    //export the structure
    $query = 'SHOW CREATE TABLE `' . $table . '`';
    $result = $dbc->prepare($query);
    $tables = $dbc->executeGetRows($result);