示例#1
0
	/**
	 * Facilitates preloading. If you want to load multiple beans at once
	 * these beans can be locked individually; given N beans this means approx.
	 * N*3 queries which is quite a lot. This method allows you to pre-lock or pre-open
	 * multiple entries at once. All beans will get an opened stamp that correspond to
	 * the first bean opened. This means this approach is conservative; it might
	 * produce a higher rate of false alarms but it does not compromise
	 * concurrency security.
	 *
	 * @param string $type type
	 * @param array  $ids  series of ids
	 */
	public function preLoad( $type, $ids ) {
		$this->adapter->exec("INSERT INTO __log (id,action,tbl,itemid)
		VALUES(NULL, :action,:tbl,:id)",array(":action"=>1,":tbl"=>"__no_type__",":id"=>0)); 
		$insertid = $this->adapter->getInsertID();
		$values = array();
		foreach($ids as $id) { 
			$this->stash[$id]=$insertid; 
			$values[] = array(1, $type, $id); 
		}
		$this->writer->insertRecord("__log",array("action","tbl","itemid"), $values); 
	}