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


PHP ActiveRecord类代码示例

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


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

示例1: GuardarAlbaranes

 public function GuardarAlbaranes()
 {
     $db = new db();
     $db->connect();
     $C = new ActiveRecord('albaranes');
     $C->fields["fecha"] = $this->fecha;
     $C->fields["operacion"] = $this->operacion;
     $C->fields["guia"] = $this->guia;
     $C->fields["remitente"] = $this->remitente;
     $C->fields["beneficiario"] = $this->beneficiario;
     $C->fields["documento"] = $this->documento;
     $C->fields["pais"] = $this->pais;
     $C->fields["direccion"] = $this->direccion;
     $C->fields["ciudad"] = $this->ciudad;
     $C->fields["telefono"] = $this->telefono;
     $C->fields["descripcion"] = $this->descripcion;
     $C->fields["peso"] = $this->peso;
     $C->fields["comision"] = $this->comision;
     $C->fields["seguro"] = $this->seguro;
     $C->fields["iv"] = $this->iv;
     $C->fields["total"] = $this->total;
     $C->fields["direccion_agencia"] = $this->direccion_agencia;
     $C->insert();
     $db->close();
 }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:25,代码来源:Pais.php

示例2: delete

 public static function delete(ActiveRecord $Record)
 {
     $modelName = $Record->getModel()->name;
     $primaryKey = $Record->getPrimaryKey();
     $pool =& self::$_pool;
     unset($pool[$modelName][$primaryKey]);
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:7,代码来源:ActiveRecordManager.php

示例3: asSQLStatement

 /**
  * @description Build WHERE Statement
  *
  * @param ActiveRecord $ar
  *
  * @throws arException
  * @return string
  */
 public function asSQLStatement(ActiveRecord $ar)
 {
     if ($this->getType() == self::TYPE_REGULAR) {
         $arField = $ar->getArFieldList()->getFieldByName($this->getFieldname());
         if ($arField instanceof arField) {
             $type = $arField->getFieldType();
             $statement = $ar->getConnectorContainerName() . '.' . $this->getFieldname();
         } else {
             $statement = $this->getFieldname();
         }
         if (is_array($this->getValue())) {
             if (in_array($this->getOperator(), array('IN', 'NOT IN', 'NOTIN'))) {
                 $statement .= ' ' . $this->getOperator() . ' (';
             } else {
                 $statement .= ' IN (';
             }
             $values = array();
             foreach ($this->getValue() as $value) {
                 $values[] = $ar->getArConnector()->quote($value, $type);
             }
             $statement .= implode(', ', $values);
             $statement .= ')';
         } else {
             if ($this->getValue() === NULL) {
                 $this->setOperator('IS');
             }
             $statement .= ' ' . $this->getOperator();
             $statement .= ' ' . $ar->getArConnector()->quote($this->getValue(), $type);
         }
         $this->setStatement($statement);
     }
     return $this->getStatement();
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:41,代码来源:class.arWhere.php

示例4: verEstado

 public static function verEstado()
 {
     $db = new db();
     $db->connect();
     $C = new ActiveRecord('lista_estados');
     $C->find(self::$id_estado);
     $db->close();
     return $C->fields;
 }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:9,代码来源:Pais.php

示例5: __construct

 public function __construct(\PDOStatement $stmt, ActiveRecord $model)
 {
     $this->stmt = $stmt;
     $this->model = $model;
     $stmt->setFetchMode(\PDO::FETCH_CLASS, $model->className(), array(false));
     //		$this->id=self::$idCount++;
     //
     //		ZLog::Write(LOGLEVEL_DEBUG, $stmt->queryString);
     //		self::$aliveStmts[$this->id]=$stmt->queryString;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:10,代码来源:ActiveStatement.php

示例6: getPages

 public function getPages()
 {
     $blog = new ActiveRecord();
     $num = $blog->size();
     $pages = $blog->pickout($num - 5, 5);
     $result = array();
     for ($i = 0; $i < 5; $i++) {
         $result[$i] = array('title' => $pages[4 - $i]->title, 'url' => "/?page={$pages[4 - $i]->pagenum}");
     }
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:11,代码来源:latestpages.php

示例7: onValidate

 public static function onValidate(ActiveRecord $Record, RecordValidator $validator)
 {
     $validator->validate(array('field' => 'Handle', 'required' => false, 'validator' => 'handle', 'errorMessage' => 'Handle can only contain letters, numbers, hyphens, and underscores'));
     // check handle uniqueness
     if ($Record->isFieldDirty('Handle') && !$validator->hasErrors('Handle') && $Record->Handle) {
         $ExistingRecord = $Record::getByHandle($Record->Handle);
         if ($ExistingRecord && $ExistingRecord->ID != $Record->ID) {
             $validator->addError('Handle', 'Handle already registered');
         }
     }
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:11,代码来源:HandleBehavior.class.php

示例8: getCategory

 public function getCategory()
 {
     $blog = new ActiveRecord();
     $blog->connectPdo('blogdb', 'categorytable', 'readonly', 'readonly');
     $categories = $blog->getValueList('category');
     $result = array();
     foreach (array_reverse($categories) as $category) {
         $result[] = array('title' => $category, 'url' => sprintf("/?category=%s", urlencode($category)));
     }
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:11,代码来源:category.php

示例9: saveModel

 protected function saveModel(ActiveRecord $model, $web_url)
 {
     if ($model->save()) {
         $model->grabImages($web_url);
         $model->grabTagsFromText();
         $this->log("Сохранена модель #{$model->id}");
     } else {
         $this->log("Не могу сохранить модель: ", impode("<br/>", $model->errors_flat_array));
     }
     return $model;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:11,代码来源:OsParser.php

示例10: unpackProps

 /**
  * ให้ค่า array ของ model ที่ได้จาก attributes + props
  * @param ActiveRecord $model
  * @return array
  */
 public static function unpackProps($model)
 {
     if ($model->hasAttribute('props')) {
         $props = json_decode($model->props, true);
         if (!is_array($props)) {
             $props = array();
         }
     } else {
         $props = array();
     }
     return $props;
 }
开发者ID:junctionaof,项目名称:thanagornfarm,代码行数:17,代码来源:JsonPackage.php

示例11: asSQLStatement

 /**
  * @param ActiveRecord $ar
  *
  * @return string
  */
 public function asSQLStatement(ActiveRecord $ar)
 {
     $return = ' ' . $this->getType() . ' ';
     $return .= ' JOIN ' . $this->getTableName() . ' AS ' . $this->getTableNameAs();
     if ($this->getBothExternal()) {
         $return .= ' ON ' . $this->getOnFirstField() . ' ' . $this->getOperator() . ' ';
     } else {
         $return .= ' ON ' . $ar->getConnectorContainerName() . '.' . $this->getOnFirstField() . ' ' . $this->getOperator() . ' ';
     }
     $return .= $this->getTableNameAs() . '.' . $this->getOnSecondField();
     return $return;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:17,代码来源:class.arJoin.php

示例12: getPages

 public function getPages($archive)
 {
     $blog = new ActiveRecord();
     $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
     $result = $blog->findLike('date', sprintf("%s/%s", explode('-', $archive)[0], explode('-', $archive)[1]) . '%');
     $pagenum_arr = array();
     foreach ($result as $page) {
         $pagenum_arr[] = $page->pagenum;
     }
     array_multisort($pagenum_arr, SORT_ASC, $result);
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:12,代码来源:archiveview.php

示例13: getKry

 public function getKry()
 {
     $objAr = new ActiveRecord();
     /*Query blm pake bind params, silahkan edit sendiri*/
     $sql = "SELECT * FROM karyawan WHERE   ";
     if ($this->getName()) {
         $sql .= " nama LIKE '%{$this->getName()}%' ";
     }
     if ($this->getNip()) {
         $sql .= " AND NIP LIKE '%{$this->getNip()}%' ";
     }
     return $objAr->fetchObject($sql);
 }
开发者ID:rakos94,项目名称:s1,代码行数:13,代码来源:kry.php

示例14: getAllMonths

 private function getAllMonths()
 {
     $blog = new ActiveRecord();
     $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
     $dates = $blog->getValueList('date');
     foreach ($dates as $date) {
         $ym[] = explode('/', $date)[0] . "-" . explode('/', $date)[1];
     }
     $ym = array_unique($ym);
     asort($ym);
     foreach ($ym as $date) {
         $result[] = ["year" => explode('-', $date)[0], "month" => explode('-', $date)[1]];
     }
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:15,代码来源:archive.php

示例15: getNextLanguage

 public function getNextLanguage()
 {
     if (!$this->languagesTruncated) {
         ActiveRecord::getDbConnection()->executeQuery('TRUNCATE TABLE Language');
         $this->languagesTruncated = true;
     }
     if (!($data = $this->loadRecord('SELECT DISTINCT code FROM ' . $this->getTablePrefix() . 'languages'))) {
         return null;
     }
     $isDefault = $this->getConfigValue('default_customer_language') == $data['code'];
     $code = $data['code'];
     if ('US' == $data['code']) {
         $data['code'] = 'en';
     }
     $data['code'] = strtolower($data['code']);
     if (!$isDefault) {
         $this->languages[$data['code']] = $code;
     } else {
         $this->defLang = $data['code'];
     }
     $lang = ActiveRecordModel::getNewInstance('Language');
     $lang->setID($data['code']);
     $lang->isEnabled->set(true);
     $lang->isDefault->set($isDefault);
     return $lang;
 }
开发者ID:saiber,项目名称:livecart,代码行数:26,代码来源:XCartImport.php


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