360 около 15 не вставляются в таблицу. Код вставки ниже:
protected function insert()
{
$this->debug('insert');
$fields = [
'type_id' => $this->object_data['realty_type'],
'location_id' => $this->object_data['location_id'],
'alias' => 'MP-' . $this->object_data['id'],
'price' => $this->object_data['price'],
'image' => '',
'desc' => $this->object_data['description'],
'panorama' => '',
'old_url' => '',
'name' => $this->object_data['title'],
'type' => '',
'new_devel' => '',
'island' => '',
'country' => '',
'area' => '',
'total_size' => $this->object_data['floorspace'],
'land_size' => $this->object_data['plot_size'],
'bed' => $this->object_data['bedrooms'],
'bath' => $this->object_data['bathrooms'],
'refur' => '',
'balc' => '',
'access' => '',
'garage' => '',
'sea_view' => $this->object_data['sea_view'],
'dist_sea' => $this->object_data['distance_to_sea'],
'dist_aer' => $this->object_data['distance_to_airport'],
'year_bilt' => '',
'floors' => $this->object_data['floors'],
'fl' => '1',
'edit' => '',
'week' => '',
'map_url' => $this->getMapUrl($this->object_data['location']),
'comp' => '',
'hot' => '',
'video' => '',
'first' => '',
];
if ($this->object_data['realty_type'] == 2) {
$fields['bed'] = '';
$fields['bath'] = '';
}
$keys = [];
$placeholders = [];
if (count($fields)) {
foreach ($fields as $key=>$values) {
$keys[] = '`' . $key . '`';
$placeholders[] = ':' . $key;
}
}
$sql = "INSERT INTO cs_objects (" . implode(', ' , $keys) . ") VALUES (" . implode(', ' , $placeholders) . ")";
//echo $sql . PHP_EOL;
//echo 'INSERT' . PHP_EOL;
$statement = $this->modx->prepare($sql);
if ($statement->execute($fields)) {
$this->object_id = $this->getObjectId($this->object_data['id']);
return true;
}
return false;
}
или как узнать причину почему не вставилась строка?
Обсуждают сегодня