• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ActiveRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __get

 function __get($key)
 {
     if ($key == "id") {
         return $this->user_id;
     }
     return ActiveRecord::__get($key);
 }
开发者ID:jkinner,项目名称:ringside,代码行数:7,代码来源:userprofilenetwork.php


示例17: testTransactionCurrencyConverting

 function testTransactionCurrencyConverting()
 {
     $eur = Currency::getNewInstance('EUR');
     $eur->rate->set('3.4528');
     $eur->save();
     $this->products[0]->setPrice($this->usd, '9.99');
     $this->order->addProduct($this->products[0], 1);
     $this->order->save();
     $this->order->changeCurrency($this->usd);
     //$this->order->finalize();
     ActiveRecord::clearPool();
     $order = CustomerOrder::getInstanceByID($this->order->getID(), true);
     $order->loadAll();
     $details = new LiveCartTransaction($order, $eur);
     ActiveRecord::clearPool();
     $order = CustomerOrder::getInstanceByID($this->order->getID(), true);
     $order->loadAll();
     $this->assertEquals($details->amount->get(), '2.89');
     $result = new TransactionResult();
     $result->amount->set($details->amount->get());
     $result->currency->set($details->currency->get());
     $transaction = Transaction::getNewInstance($order, $result);
     $transaction->type->set(Transaction::TYPE_SALE);
     $this->assertEquals($transaction->amount->get(), '9.99');
     $this->assertEquals($transaction->realAmount->get(), '2.89');
     $transaction->save();
     $this->assertFalse((bool) $order->isFinalized->get());
     $order->finalize();
     $this->assertTrue((bool) $order->isFinalized->get());
     $this->assertEquals($order->getPaidAmount(), '9.99');
     $this->assertEquals($order->totalAmount->get(), '9.99');
     $this->assertTrue((bool) $order->isPaid->get());
 }
开发者ID:saiber,项目名称:livecart,代码行数:33,代码来源:TransactionTest.php


示例18: setUp

 /** set up */
 public function setUp()
 {
     $this->createDatabase();
     Registry::put($configurator = new MockConfigurator(), '__configurator');
     Registry::put(new Logger($configurator), '__logger');
     ActiveRecord::close_connection();
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:8,代码来源:ValidatorTest.php


示例19: getPages

 public function getPages($category)
 {
     $blog = new ActiveRecord();
     $blog->connectPdo('blogdb', 'categorytable', 'readonly', 'readonly');
     $data = $blog->findFromKey('category', $category);
     $ids = array();
     foreach ($data as $row) {
         $ids[] = $row->postid;
     }
     $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
     $result = array();
     foreach ($ids as $pagenum) {
         $result[] = $blog->find($pagenum);
     }
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:16,代码来源:categoryview.php


示例20: getNewInstance

 /**
  * @return DeliveryZoneState
  */
 public static function getNewInstance(DeliveryZone $zone, $mask)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->deliveryZone->set($zone);
     $instance->mask->set($mask);
     return $instance;
 }
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:DeliveryZoneCityMask.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ActiveRecordModel类代码示例发布时间:2022-05-23
下一篇:
PHP Actions类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap