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


PHP jDao::create方法代码示例

本文整理汇总了PHP中jDao::create方法的典型用法代码示例。如果您正苦于以下问题:PHP jDao::create方法的具体用法?PHP jDao::create怎么用?PHP jDao::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jDao的用法示例。


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

示例1: view

 /**
  * displays a user
  */
 function view()
 {
     $id = $this->param('j_user_login');
     if ($id === null) {
         $rep = $this->getResponse('redirect');
         jMessage::add(jLocale::get('crud.message.bad.id', 'null'), 'error');
         $rep->action = 'default:index';
         return $rep;
     }
     $dao = jDao::create($this->dao, $this->dbProfile);
     $daorec = $dao->get($id);
     if (!$daorec) {
         $rep = $this->getResponse('redirect');
         jMessage::add(jLocale::get('crud.message.bad.id', $id), 'error');
         $rep->action = 'default:index';
         return $rep;
     }
     $rep = $this->getResponse('html');
     // we're using a form to display a record, to have the portunity to have
     // labels with each values.
     $form = jForms::create($this->form, $id);
     $form->initFromDao($this->dao, $id, $this->dbProfile);
     $tpl = new jTpl();
     $tpl->assign('id', $id);
     $tpl->assign('form', $form);
     $tpl->assign('otherInfo', jEvent::notify('jauthdbAdminGetViewInfo', array('form' => $form, 'tpl' => $tpl, 'himself' => false))->getResponse());
     $form->deactivate('password');
     $form->deactivate('password_confirm');
     $tpl->assign('canDelete', jAuth::getUserSession()->login != $id && jAcl2::check('auth.users.delete'));
     $tpl->assign('canUpdate', jAcl2::check('auth.users.modify'));
     $tpl->assign('canChangePass', jAcl2::check('auth.users.change.password'));
     $rep->body->assign('MAIN', $tpl->fetch('crud_view'));
     return $rep;
 }
开发者ID:CREASIG,项目名称:lizmap-web-client,代码行数:37,代码来源:default.classic.php

示例2: saveControlToDao

 /**
  * save data of a control using a dao.
  *
  * The control must be a container like checkboxes or listbox with multiple attribute.
  * If the form contain a new record (no formId), you should call saveToDao before
  * in order to get a new id (the primary key of the new record), or you should get a new id
  * by an other way. then you must pass this primary key in the third argument.
  * If the form has already a formId, then it will be used as a primary key, unless
  * you give one in the third argument.
  *
  * The Dao should map to an "association table" : its primary key should be
  * the primary key stored in the formId + the field which will contain one of
  * the values of the control. If this order is not the same as defined into the dao,
  * you should provide the list of property names which corresponds to the primary key
  * in this order : properties for the formId, followed by the property which contains
  * the value.
  * All existing records which have the formid in their keys are deleted
  * before to insert new values.
  *
  * @param string $controlName  the name of the control
  * @param string $daoSelector the selector of a dao file
  * @param mixed  $primaryKey the primary key if the form have no id. (optional)
  * @param mixed  $primaryKeyNames list of field corresponding to primary keys (optional)
  * @param string $dbProfile the jDb profile to use with the dao
  * @see jDao
  */
 public function saveControlToDao($controlName, $daoSelector, $primaryKey = null, $primaryKeyNames = null, $dbProfile = '')
 {
     if (!$this->controls[$controlName]->isContainer()) {
         throw new jExceptionForms('jelix~formserr.control.not.container', array($controlName, $this->sel));
     }
     $values = $this->container->data[$controlName];
     if (!is_array($values) && $values != '') {
         throw new jExceptionForms('jelix~formserr.value.not.array', array($controlName, $this->sel));
     }
     if (!$this->container->formId && !$primaryKey) {
         throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($controlName, $this->sel));
     }
     if ($primaryKey === null) {
         $primaryKey = $this->container->formId;
     }
     if (!is_array($primaryKey)) {
         $primaryKey = array($primaryKey);
     }
     $dao = jDao::create($daoSelector, $dbProfile);
     $daorec = jDao::createRecord($daoSelector, $dbProfile);
     $conditions = jDao::createConditions();
     if ($primaryKeyNames) {
         $pkNamelist = $primaryKeyNames;
     } else {
         $pkNamelist = $dao->getPrimaryKeyNames();
     }
     foreach ($primaryKey as $k => $pk) {
         $conditions->addCondition($pkNamelist[$k], '=', $pk);
         $daorec->{$pkNamelist[$k]} = $pk;
     }
     $dao->deleteBy($conditions);
     if (is_array($values)) {
         $valuefield = $pkNamelist[$k + 1];
         foreach ($values as $value) {
             $daorec->{$valuefield} = $value;
             $dao->insert($daorec);
         }
     }
 }
开发者ID:Calmacil,项目名称:ffdvh,代码行数:65,代码来源:jFormsBase.class.php

示例3: testBinaryField

 function testBinaryField()
 {
     $this->emptyTable('jsessions');
     $dao = jDao::create('jelix~jsession', $this->dbProfile);
     $sess1 = jDao::createRecord('jelix~jsession', $this->dbProfile);
     $sess1->id = 'sess_02939873A32B';
     $sess1->creation = '2010-02-09 10:28';
     $sess1->access = '2010-02-09 11:00';
     $sess1->data = chr(0) . chr(254) . chr(1);
     $res = $dao->insert($sess1);
     $this->assertEqual($res, 1, 'jDaoBase::insert does not return 1');
     $sess2 = $dao->get('sess_02939873A32B');
     $this->assertEqualOrDiff($sess2->id, $sess1->id, 'jDao::get : bad id on record');
     $this->assertEqualOrDiff(bin2hex($sess2->data), bin2hex($sess1->data), 'jDao::get : bad binary data');
 }
开发者ID:hadrienl,项目名称:jelix,代码行数:15,代码来源:jdb.pgsql.html_cli.php


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