本文整理汇总了PHP中Site::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::create方法的具体用法?PHP Site::create怎么用?PHP Site::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('sites')->delete();
for ($i = 0; $i < 5; $i++) {
for ($j = 0; $j < 5; $j++) {
Site::create(array('name' => 'BTS_' . $i . $j));
}
}
}
示例2: testHABTMKeepExisting
/**
* test HABM operations without clobbering existing records #275
*
* @return void
*/
public function testHABTMKeepExisting()
{
$this->loadFixtures('Site', 'Domain', 'DomainsSite');
$Site = new Site();
$results = $Site->find('count');
$expected = 3;
$this->assertEquals($expected, $results);
$data = $Site->findById(1);
// include api.cakephp.org
$data['Domain'] = array('Domain' => array(1, 2, 3));
$Site->save($data);
$Site->id = 1;
$results = $Site->read();
$expected = 3;
// 3 domains belonging to cakephp
$this->assertEquals($expected, count($results['Domain']));
$Site->id = 2;
$results = $Site->read();
$expected = 2;
// 2 domains belonging to markstory
$this->assertEquals($expected, count($results['Domain']));
$Site->id = 3;
$results = $Site->read();
$expected = 2;
$this->assertEquals($expected, count($results['Domain']));
$results['Domain'] = array('Domain' => array(7));
$Site->save($results);
// remove association from domain 6
$results = $Site->read();
$expected = 1;
// only 1 domain left belonging to rchavik
$this->assertEquals($expected, count($results['Domain']));
// add deleted domain back
$results['Domain'] = array('Domain' => array(6, 7));
$Site->save($results);
$results = $Site->read();
$expected = 2;
// 2 domains belonging to rchavik
$this->assertEquals($expected, count($results['Domain']));
$Site->DomainsSite->id = $results['Domain'][0]['DomainsSite']['id'];
$Site->DomainsSite->saveField('active', true);
$results = $Site->Domain->DomainsSite->find('count', array('conditions' => array('DomainsSite.active' => true)));
$expected = 5;
$this->assertEquals($expected, $results);
// activate api.cakephp.org
$activated = $Site->DomainsSite->findByDomainId(3);
$activated['DomainsSite']['active'] = true;
$Site->DomainsSite->save($activated);
$results = $Site->DomainsSite->find('count', array('conditions' => array('DomainsSite.active' => true)));
$expected = 6;
$this->assertEquals($expected, $results);
// remove 2 previously active domains, and leave $activated alone
$data = array('Site' => array('id' => 1, 'name' => 'cakephp (modified)'), 'Domain' => array('Domain' => array(3)));
$Site->create($data);
$Site->save($data);
// tests that record is still identical prior to removal
$Site->id = 1;
$results = $Site->read();
unset($results['Domain'][0]['DomainsSite']['updated']);
unset($activated['DomainsSite']['updated']);
$this->assertEquals($activated['DomainsSite'], $results['Domain'][0]['DomainsSite']);
}
示例3: createSiteAction
public function createSiteAction()
{
$domains = $this->_getParam("domains");
$domains = str_replace(" ", "", $domains);
$domains = explode(",", $domains);
$site = Site::create(array("rootId" => intval($this->_getParam("id")), "domains" => $domains));
$site->save();
$this->_helper->json($site);
}
示例4: site_create
private function site_create()
{
if (!isset($_POST['url']) || empty($_POST['url'])) {
// @todo redirect to site create page
trigger_error('Please enter a URL.', E_USER_ERROR);
exit;
}
$site = Site::create(array('url' => $_POST['url']));
// redirect to site display page
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . Options::get('base_url') . "site/?id=" . $site->id);
exit;
}
示例5: store
public function store()
{
$site = Site::create(Input::all());
Session::put('siteId', $site->id);
return $site;
}