我有简单的模型,需要将数据插入到我的表中.当我使用sql和查询时,一切正常,但当我尝试使用插入函数时,我得到一个错误,我需要使用设置?
我的数据库中的id是自动增量,日期是时间戳
class Article extends CI_Model {
private $id;
private $title;
private $text;
private $date;
public function __construct()
{
$this->load->database();
}
public function save_article($title,$text)
{
$this->title=$title;
$this->text=$text;
$this->id='';
$this->load->helper('date');
$this->date=now();
print_r($this);
//"INSERT INTO article VALUES ('','".$title."','".$text."',NOW())")
$this->db->insert('articles',$this);
}
}
Run Code Online (Sandbox Code Playgroud)
Article Object([id:Article:private] => [title:Article:private] => rrrrrrrrrrr [text:Article:private] => rrrrrrrrrrrrrrrrrr [date:Article:private] => 1351680951)
发生数据库错误
您必须使用"set"方法更新条目.
文件名:C:\ Program Files(x86)\ EasyPHP-12.1\www\blog\system\database\DB_active_rec.php
行号:1174
我有7个对象数组.每个对象都包含数据.我需要将这些数组合并在一起,我这样做:
$arrayTotal = $array1;
$arrayTotal = array_merge($arrayTotal,$array2)
$arrayTotal = array_merge($arrayTotal,$array3)
$arrayTotal = array_merge($arrayTotal,$array4)
...
Run Code Online (Sandbox Code Playgroud)
一切都很好,直到我有700个项目的总数组(每个子数组有100个项目).Apache停止响应,我认为是因为存在大量数组的内存问题.我在第4或第5次合并时遇到了问题.
合并它们并避免错误的最佳方法是什么?
更新:
[Sat Sep 15 10:17:36 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.9 configured -- resuming normal operations
[Sat Sep 15 10:17:36 2012] [notice] Server built: Sep 10 2011 11:34:11
[Sat Sep 15 10:17:36 2012] [notice] Parent: Created child process 3908
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Child process is running
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Acquired the start mutex.
[Sat Sep …
Run Code Online (Sandbox Code Playgroud)