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


PHP Model::delete方法代码示例

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


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

示例1: deletar

 public function deletar(Model $Model, $id, $cascade = false)
 {
     if ($Model->hasAny(array($Model->primaryKey => $id))) {
         return $Model->delete($id, $cascade);
     }
     throw new NotFoundException($Model->useLogger("Erro: impossível fazer a operação"));
 }
开发者ID:AmmonMa,项目名称:cake_extras,代码行数:7,代码来源:DAOBehavior.php

示例2: testMultipleUploadSaveReadDelete

 public function testMultipleUploadSaveReadDelete()
 {
     // setup
     $this->Model->Behaviors->load('Media.Attachable', array());
     $this->Model->configureAttachment(array('files' => array('baseDir' => $this->attachmentDir, 'multiple' => true, 'removeOnOverwrite' => true)), true);
     $data = array($this->Model->alias => array('title' => 'My Upload', 'files_upload' => array($this->upload1, $this->upload2)));
     // save
     $this->Model->create();
     $result = $this->Model->save($data);
     $this->assertTrue(isset($this->Model->id));
     $this->assertEqual($result[$this->Model->alias]['files_upload'], '');
     $this->assertEqual(preg_match('/Upload_File_1_([0-9a-z]+).txt,Upload_File_2_([0-9a-z]+).txt$/', $result[$this->Model->alias]['files']), 1);
     $this->assertTrue(isset($result['Attachment']['files'][0]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][0]['path']));
     $this->assertTrue(isset($result['Attachment']['files'][1]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][1]['path']));
     // read
     $modelId = $this->Model->id;
     $this->Model->create();
     $result = $this->Model->read(null, $modelId);
     $this->assertTrue(isset($result[$this->Model->alias]['files']));
     $this->assertTrue(!isset($result[$this->Model->alias]['files_upload']));
     $this->assertEqual(preg_match('/Upload_File_1_([0-9a-z]+).txt,Upload_File_2_([0-9a-z]+).txt$/', $result[$this->Model->alias]['files']), 1);
     $this->assertTrue(isset($result['Attachment']['files'][0]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][0]['path']));
     $this->assertTrue(isset($result['Attachment']['files'][1]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][1]['path']));
     //delete
     $deleted = $this->Model->delete($this->Model->id);
     $this->assertTrue($deleted, 'Failed to delete Attachment');
     $this->assertTrue(!file_exists($result['Attachment']['files'][0]['path']), 'Attachment not deleted');
     $this->assertTrue(!file_exists($result['Attachment']['files'][1]['path']), 'Attachment not deleted');
 }
开发者ID:fm-labs,项目名称:cakephp-media,代码行数:33,代码来源:AttachableBehaviorTest.php

示例3: beforeDelete

 function beforeDelete($cascade)
 {
     // Remove the extended data to be tidy.
     // First get the type id
     App::Import('Model', 'Type');
     $Type = new Type();
     $Type->recursive = -1;
     $type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
     $type_id = $type_record[0];
     // Cool, now find all node schemas
     App::Import('Model', 'NodeSchema.NodeSchema');
     $NodeSchema = new NodeSchema();
     $NodeSchema->actsAs = array('Containable');
     $schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
     // Now loop through and check for records on those tables to remove
     if (is_array($schemas) && count($schemas) > 0) {
         foreach ($schemas as $schema) {
             $table_name = $schema['NodeSchema']['table_name'];
             $model = new Model(false, $table_name);
             $model->primaryKey = 'node_id';
             // set the primary key to the node_id
             if ($model->delete($this->model->data['Node']['id'], false)) {
                 return true;
             } else {
                 // return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
             }
         }
     }
     return true;
 }
开发者ID:hgassen,项目名称:node_schema,代码行数:30,代码来源:node_schema.php

示例4: beforeSave

 /**
  * Callback
  *
  * Requires `file` field to be present if a record is created.
  *
  * Handles deletion of a record and corresponding file if the `delete` field is
  * present and has not a value of either `null` or `'0'.`
  *
  * Prevents `dirname`, `basename`, `checksum` and `delete` fields to be written to
  * database.
  *
  * Parses contents of the `file` field if present and generates a normalized path
  * relative to the path set in the `baseDirectory` option.
  *
  * @param Model $Model
  * @return boolean
  */
 function beforeSave(&$Model)
 {
     if (!$Model->exists()) {
         if (!isset($Model->data[$Model->alias]['file'])) {
             unset($Model->data[$Model->alias]);
             return true;
         }
     } else {
         if (isset($Model->data[$Model->alias]['delete']) && $Model->data[$Model->alias]['delete'] !== '0') {
             $Model->delete();
             unset($Model->data[$Model->alias]);
             return true;
         }
     }
     $blacklist = array('dirname', 'basename', 'checksum', 'delete');
     $whitelist = array('id', 'file', 'model', 'foreign_key', 'created', 'modified', 'alternative');
     foreach ($Model->data[$Model->alias] as $key => $value) {
         if (in_array($key, $whitelist)) {
             continue;
         }
         if (in_array($key, $blacklist)) {
             unset($Model->data[$Model->alias][$key]);
         }
     }
     extract($this->settings[$Model->alias]);
     if (isset($Model->data[$Model->alias]['file'])) {
         $File = new File($Model->data[$Model->alias]['file']);
         /* `baseDirectory` may equal the file's directory or use backslashes */
         $dirname = substr(str_replace(str_replace('\\', '/', $baseDirectory), null, str_replace('\\', '/', Folder::slashTerm($File->Folder->pwd()))), 0, -1);
         $result = array('dirname' => $dirname, 'basename' => $File->name);
         $Model->data[$Model->alias] = array_merge($Model->data[$Model->alias], $result);
     }
     return true;
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:51,代码来源:coupler.php

示例5: delete

 function delete()
 {
     $delete_result = parent::delete();
     $task = new Task($this->task_id);
     $task->update_total_time();
     return $delete_result;
 }
开发者ID:neevan1e,项目名称:Done,代码行数:7,代码来源:timeentry.php

示例6: destroy

 /**
  * Удаляет текущую запись
  */
 public function destroy()
 {
     //Делаем запрос на удаление
     $this->_model_instance->delete($this->{$this->_pkey});
     //Если есть связь с другими таблицами
     if ($this->_has_many) {
         foreach ($this->_has_many as $table) {
             //Строим название модели
             $model = "Model_" . ucfirst($table);
             /**
              * Получаем объект записи
              * @var $model Model
              */
             $model = new $model();
             //Ищем объекты
             $rows = $model->where(array($this->_table . "_id" => $this->{$this->_pkey}))->row_all();
             if ($rows) {
                 /**
                  * @var $row Model_Row
                  */
                 foreach ($rows as $row) {
                     $row->destroy();
                 }
             }
         }
     }
 }
开发者ID:pnixx,项目名称:boot,代码行数:30,代码来源:row.php

示例7: deleteById

 /**
  * @param int $id
  * @throws DbalException
  * @return array
  */
 public function deleteById($id)
 {
     if (!intval($id)) {
         throw new DbalException('Id required');
     }
     return $this->model->delete($this->table, $this->idColum, intval($id));
 }
开发者ID:kxopa,项目名称:slim-boilerplate,代码行数:12,代码来源:TableModel.php

示例8: delete

 public function delete($id = null, $cascade = true)
 {
     $result = parent::delete($id, $cascade);
     if ($result === false && $this->Behaviors->enabled('SoftDelete')) {
         return $this->field('deleted', array('deleted' => 1));
     }
     return $result;
 }
开发者ID:klapp303,项目名称:sister,代码行数:8,代码来源:AppModel.php

示例9: delete

 public function delete()
 {
     //delete all our tokens
     db()->execute("\n\t\t\t\tDELETE FROM oauth_token WHERE consumer_id = {$this->id}\n\t\t\t");
     //delete all our nonces
     db()->execute("\n\t\t\t\tDELETE FROM oauth_token_nonce WHERE consumer_id = {$this->id}\n\t\t\t");
     parent::delete();
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:8,代码来源:oauthconsumer.php

示例10: delete

 public function delete()
 {
     if ($this->isHydrated()) {
         $s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
         $s3->deleteObject($this->get('bucket'), $this->get('path'));
     }
     parent::delete();
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:8,代码来源:s3file.php

示例11: delete

 /**
  * Deletes a server
  */
 public function delete($server_id)
 {
     # Deletes invoice upon invoice id
     global $main;
     $this->setId($server_id);
     parent::delete();
     $main->addLog("server:delete id #{$id} deleted ");
     return true;
 }
开发者ID:codegooglecom,项目名称:bnpanel,代码行数:12,代码来源:class_server.php

示例12: delete

 /**
  * Delete a particular item from the model.
  * @param $params
  * @return unknown_type
  */
 public function delete($params)
 {
     if (User::getPermission($this->permissionPrefix . "_can_delete")) {
         $data = $this->model->getWithField($this->model->getKeyField(), $params[0]);
         $this->model->delete($this->model->getKeyField(), $params[0]);
         User::log("Deleted " . $this->model->name, $data[0]);
         Application::redirect("{$this->urlPath}?notification=Successfully+deleted+" . strtolower($this->label));
     }
 }
开发者ID:rocksyne,项目名称:wyf,代码行数:14,代码来源:ModelController.php

示例13: test_delete_returnsSelf_ifModelDoesHaveId

 /**
  * delete() should return self if model does have id
  */
 public function test_delete_returnsSelf_ifModelDoesHaveId()
 {
     $client = new Api\Client();
     $model = new Model($client);
     $model->id = 1;
     $model->delete();
     $this->assertNull($model->id);
     return;
 }
开发者ID:jstewmc,项目名称:active-resource-model,代码行数:12,代码来源:ModelTest.php

示例14: destroy

 public static function destroy($id)
 {
     //construct query to delete
     $sql = 'DELETE FROM posts WHERE id = ' . $id;
     //send that query to the Model class that Posts extends
     $results = Model::delete($sql);
     //return results to controller
     return $results;
 }
开发者ID:SafirX,项目名称:gdi-php-mvc,代码行数:9,代码来源:post.php

示例15: delete

 public function delete()
 {
     $_where = array("id='{$this->_R['id']}'");
     $_service = parent::select(array('first'), array('where' => $_where, 'limit' => '1'));
     if ($_service[0]->first == 1) {
         return 0;
     } else {
         return parent::delete($_where);
     }
 }
开发者ID:yjf0503,项目名称:Mall,代码行数:10,代码来源:ServiceModel.class.php


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