Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
36
homestead/application/models/PlaceModel.php
Normal file
36
homestead/application/models/PlaceModel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class PlaceModel extends MY_Model
|
||||
{
|
||||
private $table = 'cm_naver_place';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function save($places)
|
||||
{
|
||||
$inserted = array();
|
||||
foreach($places[0]->data->places->items as $place) {
|
||||
if($this->db->where('NId', $place->id)->from($this->table)->count_all_results() == 0) {
|
||||
if($this->db->insert($this->table, array(
|
||||
'NId' => $place->id,
|
||||
'Category' => $place->category,
|
||||
'Name' => $place->name,
|
||||
'RoadAddress' => $place->roadAddress,
|
||||
'Address' => $place->address,
|
||||
'CommonAddress' => $place->commonAddress,
|
||||
'Phone' => $place->phone,
|
||||
'X' => $place->x,
|
||||
'Y' => $place->y,
|
||||
'CreatedAt' => date('Y-m-d H:i:s'),
|
||||
)))
|
||||
array_push($inserted, $this->db->insert_id());
|
||||
}
|
||||
}
|
||||
return ['inserted' => $inserted];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user