本文整理汇总了PHP中District::save方法的典型用法代码示例。如果您正苦于以下问题:PHP District::save方法的具体用法?PHP District::save怎么用?PHP District::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类District
的用法示例。
在下文中一共展示了District::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = Input::all();
$district = new District();
$district->name = $data['name'];
try {
$district->save();
} catch (ValidationException $errors) {
return Redirect::route('admin.districts.create')->withErrors($errors->getErrors())->withInput();
}
return Redirect::route('admin.districts.create')->withErrors(array('mainSuccess' => 'Областта е добавена.'));
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new District();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['District'])) {
$model->attributes = $_POST['District'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例3: actionCreate
/**
* 录入
*
*/
public function actionCreate()
{
parent::_acl('district_create');
$model = new District();
if (isset($_POST['District'])) {
$model->attributes = $_POST['District'];
if ($model->save()) {
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入地区,ID:' . $model->id));
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model));
}
示例4: actionCreate
public function actionCreate()
{
$model = new District();
if (isset($_POST['District'])) {
$model->setAttributes($_POST['District']);
if ($model->save()) {
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->end();
} else {
$this->redirect(array('view', 'id' => $model->id));
}
}
}
$this->render('create', array('model' => $model));
}
示例5: save
public function save()
{
$name = $this->input->post("name");
$province = $this->input->post("province");
$latitude = $this->input->post("latitude");
$longitude = $this->input->post("longitude");
$district_id = $this->input->post("district_id");
//Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
if (strlen($district_id) > 0) {
$district = District::getDistrict($district_id);
$district = $district[0];
} else {
$district = new District();
}
$district->Name = $name;
$district->Province = $province;
$district->Latitude = $latitude;
$district->Longitude = $longitude;
$district->save();
redirect("district_management");
}
示例6: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
// create connection to import database
$this->logSection('connection', 'creating connection to import source');
$source = Propel::getConnection($options['source'] ? $options['source'] : null);
// create static counties and offices
$this->logSection('static', 'creating static counties and offices');
$connection->beginTransaction();
try {
OfficePeer::doDeleteAll($connection);
$o1 = new Office();
$o1->setName('Plattsburgh');
$o1->save($connection);
$o1 = new Office();
$o1->setName('Rouses Point');
$o1->save($connection);
CountyPeer::doDeleteAll($connection);
$c1 = new County();
$c1->setName('Clinton');
$c1->save($connection);
$c1 = new County();
$c1->setName('Essex');
$c1->save($connection);
$connection->commit();
} catch (PropelException $e) {
$connection->rollBack();
throw $e;
}
// read in and create objects for district, frequency, icd9, job, services tables
// DISTRICT
$query = 'SELECT * FROM %s';
$query = sprintf($query, 'tbl_district');
$statement = $source->prepare($query);
$statement->execute();
$districts = $statement->fetchAll();
$connection->beginTransaction();
try {
DistrictPeer::doDeleteAll($connection);
foreach ($districts as $district) {
$this->logSection('district', 'creating district ' . $district['district_name']);
$d1 = new District();
$d1->setName($district['district_name']);
$d1->save($connection);
}
$connection->commit();
} catch (PropelException $e) {
$connection->rollBack();
throw $e;
}
// FREQUENCY
$query = 'SELECT * FROM %s';
$query = sprintf($query, 'tbl_frequency');
$statement = $source->prepare($query);
$statement->execute();
$frequencies = $statement->fetchAll();
$connection->beginTransaction();
try {
FrequencyPeer::doDeleteAll($connection);
foreach ($frequencies as $freq) {
$this->logSection('freq', 'reading frequency ' . $freq['freq_title']);
$f1 = new Frequency();
$f1->setName($freq['freq_title']);
$f1->setDescription($freq['freq_description']);
$f1->save($connection);
}
$connection->commit();
} catch (PropelException $e) {
$connection->rollBack();
throw $e;
}
// ICD9
$query = 'SELECT * FROM %s';
$query = sprintf($query, 'tbl_icd9');
$statement = $source->prepare($query);
$statement->execute();
$icd9s = $statement->fetchAll();
$connection->beginTransaction();
try {
Icd9Peer::doDeleteAll($connection);
foreach ($icd9s as $icd9) {
$this->logSection('icd9', 'reading icd9 ' . $icd9['icd9_value']);
$i1 = new Icd9();
$i1->setName($icd9['icd9_value']);
$i1->save($connection);
}
$connection->commit();
} catch (PropelException $e) {
$connection->rollBack();
throw $e;
}
// JOB
$query = 'SELECT * FROM %s';
$query = sprintf($query, 'tbl_job');
$statement = $source->prepare($query);
$statement->execute();
$jobs = $statement->fetchAll();
$connection->beginTransaction();
//.........这里部分代码省略.........
示例7: getRows
public function getRows($pq)
{
$rows = $pq->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$n = count($rows);
echo 'Jumlah propinsi: ' . $n . " \n";
$count = 0;
foreach ($rows as $value) {
$count++;
$row = pq($value);
$kolom_provinsi = $row->find('td:eq(1) > a');
$nama_provinsi = $kolom_provinsi->text();
$link_provinsi = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolom_provinsi->attr('href')) . '&perhal=1000';
echo sprintf("Memproses propinsi %d dari %d\n", $count, $n);
echo sprintf("Propinsi: %s Link: %s\n", $nama_provinsi, $link_provinsi);
$province = Province::model()->findByAttributes(array('name' => $nama_provinsi));
if (!$province instanceof Province) {
$province = new Province();
$province->name = $nama_provinsi;
if (!$province->save()) {
throw new CException('Cannot save province');
}
}
$countdistrict = 0;
$pqDist = phpQuery::newDocumentHtml($this->getContents($link_provinsi));
$rowsDist = $pqDist->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nDist = count($rowsDist);
$countDist = 0;
foreach ($rowsDist as $valueDist) {
$countDist++;
$rowDist = pq($valueDist);
switch ($rowDist->find('td:eq(2)')->text()) {
case 'Kota':
$tipeDist = 'kota';
break;
default:
case 'Kab.':
$tipeDist = 'kabupaten';
break;
}
$kolomDist = $rowDist->find('td:eq(3) > a');
$namaDist = $kolomDist->text();
$linkDist = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomDist->attr('href')) . '&perhal=1000';
echo sprintf("Memproses distrik " . $province->name . " %d dari %d\n", $countDist, $nDist);
echo sprintf("Distrik: %s Link: %s\n", $namaDist, $linkDist);
$distrik = District::model()->findByAttributes(array('name' => $namaDist, 'province_id' => $province->id, 'type' => $tipeDist));
if (!$distrik instanceof District) {
$distrik = new District();
$distrik->name = $namaDist;
$distrik->type = $tipeDist;
$distrik->province_id = $province->id;
if (!$distrik->save()) {
throw new CException('Cannot save district');
}
}
$pqZone = phpQuery::newDocumentHtml($this->getContents($linkDist));
$rowsZone = $pqZone->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nZone = count($rowsZone);
$countZone = 0;
foreach ($rowsZone as $valueZone) {
$countZone++;
$rowZone = pq($valueZone);
$kolomZone = $rowZone->find('td:eq(4) > a');
$namaZone = $kolomZone->text();
$linkZone = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomZone->attr('href')) . '&perhal=1000';
echo sprintf("Memproses zone %d dari %d\n", $countZone, $nZone);
echo sprintf("zone: %s Link: %s\n", $namaZone, $linkZone);
$new_zone = false;
$zone = Zone::model()->findByAttributes(array('name' => $namaZone, 'district_id' => $distrik->id));
if (!$zone instanceof Zone) {
$zone = new Zone();
$zone->name = $namaZone;
$zone->active = 1;
$zone->district_id = $distrik->id;
if (!$zone->save()) {
throw new CException('Cannot save Zone');
}
$new_zone = true;
}
echo 'sukses saving zone' . "\n";
$countArea = 0;
$pqArea = phpQuery::newDocumentHtml($this->getContents($linkZone));
$rowsArea = $pqArea->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nArea = count($rowsArea);
// Let's speed up things a bit
$trans = Yii::app()->db->beginTransaction();
foreach ($rowsArea as $valueArea) {
$countArea++;
$rowArea = pq($valueArea);
$kolomArea = $rowArea->find('td:eq(2) > a');
$kolomKodePos = $rowArea->find('td:eq(1)');
$namaArea = $kolomArea->text();
$kodePos = $kolomKodePos->text();
$linkKodePos = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomArea->attr('href')) . '&perhal=1000';
$area = $new_zone ? null : Area::model()->findByAttributes(array('name' => $namaArea, 'zone_id' => $zone->id));
if (!$area instanceof Area) {
$area = new Area();
$area->name = $namaArea;
$area->postcode = $kodePos;
$area->zone_id = $zone->id;
if (!$area->save()) {
//.........这里部分代码省略.........
示例8: save
public function save($table = "")
{
if ($table == "counties") {
$county_name = $this->input->post("name");
$new_county = new Counties();
$new_county->county = $county_name;
$new_county->save();
$this->session->set_userdata('msg_success', 'County: ' . $county_name . ' was Added');
$this->session->set_userdata('default_link', 'addCounty');
} else {
if ($table == "facilities") {
$satellite_code = $this->input->post("facility");
if ($satellite_code) {
$central_code = $this->session->userdata("facility");
$sql = "update facilities set parent='{$central_code}' where facilitycode='{$satellite_code}'";
$this->db->query($sql);
$this->session->set_userdata('msg_success', 'Facility No: ' . $satellite_code . ' was Added as a Satellite');
}
$this->session->set_userdata('default_link', 'addSatellite');
} else {
if ($table == "district") {
$disrict_name = $this->input->post("name");
$new_district = new District();
$new_district->Name = $disrict_name;
$new_district->save();
$this->session->set_userdata('msg_success', 'District: ' . $disrict_name . ' was Added');
$this->session->set_userdata('default_link', 'addDistrict');
} else {
if ($table == "menu") {
$menu_name = $this->input->post("menu_name");
$menu_url = $this->input->post("menu_url");
$menu_desc = $this->input->post("menu_description");
$new_menu = new Menu();
$new_menu->Menu_Text = $menu_name;
$new_menu->Menu_Url = $menu_url;
$new_menu->Description = $menu_desc;
$new_menu->save();
$this->session->set_userdata('msg_success', 'Menu: ' . $menu_name . ' was Added');
$this->session->set_userdata('default_link', 'addMenu');
} else {
if ($table == "faq") {
$faq_module = $this->input->post("faq_module");
$faq_question = $this->input->post("faq_question");
$faq_answer = $this->input->post("faq_answer");
$new_faq = new Faq();
$new_faq->modules = $faq_module;
$new_faq->questions = $faq_question;
$new_faq->answers = $faq_answer;
$new_faq->save();
$this->session->set_userdata('msg_success', 'FAQ was Added');
$this->session->set_userdata('default_link', 'addFAQ');
} else {
if ($table == "users") {
//default password
$default_password = '123456';
$user_data = array('Name' => $this->input->post('fullname', TRUE), 'Username' => $this->input->post('username', TRUE), 'Password' => md5($this->encrypt->get_key() . $default_password), 'Access_Level' => $this->input->post('access_level', TRUE), 'Facility_Code' => $this->input->post('facility', TRUE), 'Created_By' => $this->session->userdata('user_id'), 'Time_Created' => date('Y-m-d,h:i:s A'), 'Phone_Number' => $this->input->post('phone', TRUE), 'Email_Address' => $this->input->post('email', TRUE), 'Active' => 1, 'Signature' => 1);
$this->db->insert("users", $user_data);
$this->session->set_userdata('msg_success', 'User: ' . $this->input->post('fullname', TRUE) . ' was Added');
$this->session->set_userdata('default_link', 'addUsers');
} else {
if ($table == "user_right") {
$access_level = $this->input->post("access_level");
$menu = $this->input->post("menus");
if ($menu) {
$new_right = new User_Right();
$new_right->Access_Level = $access_level;
$new_right->Menu = $menu;
$new_right->Access_Type = "4";
$new_right->save();
$this->session->set_userdata('msg_success', 'User Right was Added');
$this->session->set_userdata('default_link', 'assignRights');
}
}
}
}
}
}
}
}
redirect("home_controller/home");
}