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


PHP Article::set方法代码示例

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


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

示例1: test_multilingual_setting_an_specific_locale

 public function test_multilingual_setting_an_specific_locale()
 {
     $Article = new Article();
     $Article->set('headline', 'Happiness on developers boost productivity', 'en');
     $Article->set('headline', 'La felicidad de los programadores mejora la productivdad', 'es');
     $this->assertEqual($Article->en_headline, 'Happiness on developers boost productivity');
     $this->assertEqual($Article->es_headline, 'La felicidad de los programadores mejora la productivdad');
 }
开发者ID:bermi,项目名称:akelos,代码行数:8,代码来源:i18n.php

示例2: Article

 function test_multilingual_setting()
 {
     $Article = new Article();
     $Article->set('headline', array('en' => 'New PHP Framework released', 'es' => 'Se ha liberado un nuevo Framework para PHP'));
     $Article->set('body', array('en' => 'The Akelos Framework has been released...', 'es' => 'Un equipo de programadores españoles ha lanzado un entorno de desarrollo para PHP...'));
     $Article->set('excerpt_limit', array('en' => 7, 'es' => 3));
     $this->assertTrue($Article->save());
     $Article = $Article->find($Article->getId());
     $this->assertEqual($Article->get('en_headline'), 'New PHP Framework released');
     $this->assertEqual($Article->get('es_body'), 'Un equipo de programadores españoles ha lanzado un entorno de desarrollo para PHP...');
     $this->assertEqual($Article->get('en_excerpt_limit'), 7);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:12,代码来源:_AkActiveRecord_i18n.php

示例3: testSaveAllWithSet

 /**
  * test that saveAll still behaves like previous versions (does not necessarily need a first argument)
  *
  * @return void
  */
 public function testSaveAllWithSet()
 {
     $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag');
     $data = array('Article' => array('user_id' => 1, 'title' => 'Article Has and belongs to Many Tags'), 'Tag' => array('Tag' => array(1, 2)), 'Comment' => array(array('comment' => 'Article comment', 'user_id' => 1)));
     $Article = new Article();
     $Article->set($data);
     $result = $Article->saveAll();
     $this->assertFalse(empty($result));
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:14,代码来源:ModelWriteTest.php

示例4: testDeleteAll

 /**
  * testDeleteAll method
  *
  * @return void
  */
 public function testDeleteAll()
 {
     $this->loadFixtures('Article');
     $TestModel = new Article();
     $data = array('Article' => array('user_id' => 2, 'id' => 4, 'title' => 'Fourth Article', 'published' => 'N'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $data = array('Article' => array('user_id' => 2, 'id' => 5, 'title' => 'Fifth Article', 'published' => 'Y'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $data = array('Article' => array('user_id' => 1, 'id' => 6, 'title' => 'Sixth Article', 'published' => 'N'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published'), 'order' => array('Article.id' => 'ASC')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')), array('Article' => array('id' => 4, 'user_id' => 2, 'title' => 'Fourth Article', 'published' => 'N')), array('Article' => array('id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y')), array('Article' => array('id' => 6, 'user_id' => 1, 'title' => 'Sixth Article', 'published' => 'N')));
     $this->assertEquals($expected, $result);
     $result = $TestModel->deleteAll(array('Article.published' => 'N'));
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published'), 'order' => array('Article.id' => 'ASC')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')), array('Article' => array('id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y')));
     $this->assertEquals($expected, $result);
     $data = array('Article.user_id' => array(2, 3));
     $result = $TestModel->deleteAll($data, true, true);
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published'), 'order' => array('Article.id' => 'ASC')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')));
     $this->assertEquals($expected, $result);
     $result = $TestModel->deleteAll(array('Article.user_id' => 999));
     $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
 }
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:38,代码来源:ModelDeleteTest.php

示例5: testSaveHabtm

 /**
  * testSaveHabtm method
  *
  * @return void
  */
 public function testSaveHabtm()
 {
     $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'ArticlesTag');
     $TestModel = new Article();
     $result = $TestModel->findById(2);
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 'User' => array('id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'), 'Comment' => array(array('id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'), array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Article' => array('id' => '2', 'title' => 'New Second Article'), 'Tag' => array('Tag' => array(1, 2)));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')));
     $this->assertEquals($expected, $result);
     $data = array('Article' => array('id' => '2'), 'Tag' => array('Tag' => array(2, 3)));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(1, 2, 3)));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array()));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $data = array('Tag' => array('Tag' => ''));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array());
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(2, 3)));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(1, 2)), 'Article' => array('id' => '2', 'title' => 'New Second Article'));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(1, 2)), 'Article' => array('id' => '2', 'title' => 'New Second Article Title'));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'New Second Article Title', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(2, 3)), 'Article' => array('id' => '2', 'title' => 'Changed Second Article'));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Tag' => array('Tag' => array(1, 3)), 'Article' => array('id' => '2'));
     $result = $TestModel->set($data);
     $this->assertFalse(empty($result));
     $result = $TestModel->save();
     $this->assertFalse(empty($result));
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
     $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $data = array('Article' => array('id' => 10, 'user_id' => '2', 'title' => 'New Article With Tags and fieldList', 'body' => 'New Article Body with Tags and fieldList', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31'), 'Tag' => array('Tag' => array(1, 2, 3)));
     $result = $TestModel->create() && $TestModel->save($data, true, array('user_id', 'title', 'published'));
//.........这里部分代码省略.........
开发者ID:mbp-informatics,项目名称:payments.mousebiology.org,代码行数:101,代码来源:ModelWriteTest.php

示例6: testOnRequiredConflictValidation

 /**
  * Test that 'required' and 'on' are not conflicting
  *
  * @return void
  */
 public function testOnRequiredConflictValidation()
 {
     $this->loadFixtures('Article');
     $Article = new Article();
     // no title field present
     $data = array('Article' => array('body' => 'Extra Fields Body', 'published' => '1'));
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'create', 'on' => 'create')));
     $Article->create($data);
     $this->assertFalse($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'update', 'on' => 'create')));
     $Article->create($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'create', 'on' => 'update')));
     $Article->create($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'update', 'on' => 'update')));
     $Article->create($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'create', 'on' => 'create')));
     $Article->save(null, array('validate' => false));
     $data['Article']['id'] = $Article->id;
     $Article->set($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'update', 'on' => 'create')));
     $Article->set($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'create', 'on' => 'update')));
     $Article->set($data);
     $this->assertTrue($Article->validates());
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => 'update', 'on' => 'update')));
     $Article->set($data);
     $this->assertFalse($Article->validates());
 }
开发者ID:kuradakis,项目名称:cakephp-ex,代码行数:38,代码来源:ModelValidationTest.php

示例7: testDeleteAll

 /**
  * testDeleteAll method
  *
  * @access public
  * @return void
  */
 public function testDeleteAll()
 {
     $this->loadFixtures('Article');
     $TestModel = new Article();
     $data = array('Article' => array('user_id' => 2, 'id' => 4, 'title' => 'Fourth Article', 'published' => 'N'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $data = array('Article' => array('user_id' => 2, 'id' => 5, 'title' => 'Fifth Article', 'published' => 'Y'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $data = array('Article' => array('user_id' => 1, 'id' => 6, 'title' => 'Sixth Article', 'published' => 'N'));
     $result = $TestModel->set($data) && $TestModel->save();
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')), array('Article' => array('id' => 4, 'user_id' => 2, 'title' => 'Fourth Article', 'published' => 'N')), array('Article' => array('id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y')), array('Article' => array('id' => 6, 'user_id' => 1, 'title' => 'Sixth Article', 'published' => 'N')));
     $this->assertEqual($expected, $result);
     $result = $TestModel->deleteAll(array('Article.published' => 'N'));
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')), array('Article' => array('id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y')));
     $this->assertEqual($expected, $result);
     $data = array('Article.user_id' => array(2, 3));
     $result = $TestModel->deleteAll($data, true, true);
     $this->assertTrue($result);
     $TestModel->recursive = -1;
     $result = $TestModel->find('all', array('fields' => array('id', 'user_id', 'title', 'published')));
     $expected = array(array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y')), array('Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y')));
     $this->assertEqual($expected, $result);
     $result = $TestModel->deleteAll(array('Article.user_id' => 999));
     $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
     $this->expectError();
     ob_start();
     $result = $TestModel->deleteAll(array('Article.non_existent_field' => 999));
     ob_get_clean();
     $this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s');
 }
开发者ID:Nervie,项目名称:Beta,代码行数:44,代码来源:ModelDeleteTest.php

示例8: testStateValidation

 /**
  * Test for 'on' => [create|update] in validation rules.
  *
  * @return void
  */
 function testStateValidation()
 {
     $this->loadFixtures('Article');
     $Article = new Article();
     $data = array('Article' => array('title' => '', 'body' => 'Extra Fields Body', 'published' => '1'));
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'on' => 'create')));
     $Article->create($data);
     $this->assertFalse($Article->validates());
     $Article->save(null, array('validate' => false));
     $data['Article']['id'] = $Article->id;
     $Article->set($data);
     $this->assertTrue($Article->validates());
     unset($data['Article']['id']);
     $Article->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'on' => 'update')));
     $Article->create($data);
     $this->assertTrue($Article->validates());
     $Article->save(null, array('validate' => false));
     $data['Article']['id'] = $Article->id;
     $Article->set($data);
     $this->assertFalse($Article->validates());
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:26,代码来源:ModelValidationTest.php

示例9: Connection

<?php

header('Content-Type: text/plain; charset=utf-8');
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/classes.php';
use Orange\Database\Connection;
$config = json_decode(file_get_contents(__DIR__ . '/config.json'), true);
try {
    $connection = new Connection($config);
    // Initialize connection
    Article::install();
    User::install();
    $user = new User('login', 'admin');
    if (!$user->id) {
        $data = array('login' => 'admin', 'name' => 'Administrator', 'email' => 'info@example.org', 'status' => true);
        $user->setData($data)->save();
    }
    $article = new Article();
    $article->set('title', 'My article number one')->set('content', 'Text of my first article')->set('user_id', $user->id)->save();
} catch (\Orange\Database\DBException $e) {
    echo 'Orange database exception: ' . $e->getMessage() . (($query = $e->getQuery()) ? ". Query:\n" . $query . "\n" . $e->getTraceAsString() . "\n" : '');
}
开发者ID:charger88,项目名称:orange.database,代码行数:22,代码来源:active-record.php

示例10: beforeSave

 /**
  * Override modResourceCreateProcessor::beforeSave to provide archiving
  *
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSave()
 {
     $beforeSave = parent::beforeSave();
     if (!$this->parentResource) {
         $this->parentResource = $this->object->getOne('Parent');
     }
     if ($this->object->get('published')) {
         if (!$this->setArchiveUri()) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set URI for new Article.');
         }
     }
     /** @var ArticlesContainer $container */
     $container = $this->modx->getObject('ArticlesContainer', $this->object->get('parent'));
     if ($container) {
         $settings = $container->getProperties('articles');
         $this->object->setProperties($settings, 'articles');
         $this->object->set('richtext', !isset($settings['articlesRichtext']) || !empty($settings['articlesRichtext']));
     }
     $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published');
     return $beforeSave;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:27,代码来源:article.class.php

示例11: beforeSave

 /**
  * Override modResourceUpdateProcessor::beforeSave to provide archiving
  *
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSave()
 {
     $afterSave = parent::beforeSave();
     $container = $this->modx->getObject('ArticlesContainer', $this->object->get('parent'));
     if ($this->object->get('published') && ($this->object->isDirty('alias') || $this->object->isDirty('published'))) {
         if (!$this->setArchiveUri()) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set date URI.');
         }
     } else {
         if ($this->object->get('pub_date') && $this->object->isDirty('pub_date') || $this->object->isDirty('pub_date')) {
             if (!$this->setArchiveUri()) {
                 $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set date URI pub_date.');
             }
         } else {
             if (!$this->object->get('published') && !$this->object->get('pub_date')) {
                 // we need to always do this because the url may have been set previously by pub_date
                 /*$containerUri = $container->get('uri');
                   if (empty($containerUri)) {
                       $containerUri = $container->get('alias');
                   }*/
                 $uri = rtrim($this->object->get('alias'));
                 $this->object->set('uri', $uri);
                 $this->object->set('uri_override', true);
             }
         }
     }
     /** @var ArticlesContainer $container */
     if ($container) {
         $this->object->setProperties($container->getProperties('articles'), 'articles');
     }
     $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published');
     return $afterSave;
 }
开发者ID:rafull6,项目名称:texno-service,代码行数:39,代码来源:article.class.php

示例12: genererRss

function genererRss()
{
    $article = new Article();
    $article->set('pageNews', 'oui');
    $arch = new Archiviste();
    $articles = $arch->restituer($article);
    $rssGen = new RssGen();
    $rssGen->setArtList($articles);
    $rssGen->generer();
}
开发者ID:selenith,项目名称:plasmide,代码行数:10,代码来源:admin.php


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