public function addPharmacy($attr) { $model = new Pharmacy(); $model->setAttributes($attr); if ($model->save(FALSE)) { return TRUE; } return FALSE; }
public function actionAddPharmacy() { $attr = StringHelper::filterArrayString($_POST); $model = new Pharmacy(); $model->setAttributes($attr); // $model->created_at = time(); //$model->updated_at = time(); if ($model->save(FALSE)) { ResponseHelper::JsonReturnSuccess("", "Success"); } else { ResponseHelper::JsonReturnError("", "Server Error"); } }
public function actionIndex() { $i = 1; for ($i = 1; $i < 2; $i++) { $simpleHTML = new SimpleHTMLDOM(); $html = $simpleHTML->file_get_html("http://www.healthfamily.co/danh-sach-nha-thuoc-hieu-thuoc?p={$i}&r=100#.VavHvXj0HuU"); foreach ($html->find('div.h125') as $element) { $name = $element->find('h3 a')->innertext; // $address = $element->find('p.date-time', 0)->innertext; $pharmacy = new Pharmacy(); $pharmacy->name = $name; $pharmacy->address = ""; $pharmacy->save(FALSE); } } $this->render('index'); }