Skip to content

Instantly share code, notes, and snippets.

@raf-sh
Created May 13, 2013 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raf-sh/5567674 to your computer and use it in GitHub Desktop.
Save raf-sh/5567674 to your computer and use it in GitHub Desktop.
\models\classified.php
public function save($data)
{
$table = $this->getTable();
$ads['text'] = iconv("cp1251", "UTF-8", $date['shptext']);
$ads['phone'] = $data['shpphone'];
$ads['quantity'] = $data['shpquantity'];
$ads['author'] = iconv("cp1251", "UTF-8", $data['shpname']);
$ads['ad_type'] = $data['shpview'];
$ads['cat'] = $data['category'];
$ads['publish_date'] = '01.01.1991';
$ads['checked'] = 0;
$ads['money'] = $data['OutSum'];
// привязываем поля формы к таблице
if (!$table->bind($ads))
{
$this->setError($table->getError());
return false;
}
// проверяем данные
if ($table->check($ads))
{
// сохраняем данные
if (!$table->store($ads))
{
$this->setError($table->getError());
return false;
}
}
else
{
$this->setError($table->getError());
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment