示例#1
0
// if ($p->count() == 0) {
//   $title[] = 'Contacts';
// } else {
//   $a_id = $p->getItem(1)->name;
//   $z_id = $p->getItem($p->getCurrentItemCount())->name;
//
//   $title[] = sprintf('%s through %s',$a_id,$z_id);
// }
// $title[] = sprintf('Page %d of %d',$page->getCurrentPageNumber(),$page->count());
$_ENV['title'] = $title;
// $this->view->Page = $p;
/*
$rq = $this->getRequest();
// Automatic Query?
if ($a = $rq->getQuery('a')) {
}

	//$ss->where('kind_id in (100,300)');
	$sql->order(array('contact','company'));
$sql->limitPage($this->view->Paginator->page,$this->view->Paginator->limit);

// View!
	$this->view->ContactList = $db->fetchAll($sql);
	$this->view->title = array(
  'Contacts',
  'Page ' . $this->view->Paginator->page . ' of ' . $this->view->Paginator->pmax,
  );
*/
$this->ContactList = SQL::fetch_all($sql, $arg);
Session::flash('fail', SQL::lastError());
示例#2
0
 /**
 	AppModel Save
 	@todo use the _data interface, check for dirty
 */
 function save()
 {
     // Set Sane Defaults
     // if (empty($this->_data['auth_user_id'])) {
     //	 $this->_data['auth_user_id'] = $_SESSION['uid']; // $cu->id;
     // }
     // if (empty($this->_data['hash'])) $this->_data['hash'] = $this->hash();
     // Set some Fields to Null
     // if (empty($this->_data['link_to'])) $this->_data['link_to'] = null;
     // if (empty($this->_data['link_id'])) $this->_data['link_id'] = null;
     if (isset($this->_data['link_to'])) {
         if (empty($this->_data['link_to'])) {
             $this->_data['link_to'] = null;
         }
     }
     if (isset($this->_data['link_id'])) {
         if (empty($this->_data['link_id'])) {
             $this->_data['link_id'] = null;
         }
     }
     // Convert to Array
     // $rec = array();
     // foreach ($this->_properties as $k) {
     //	 if (empty($this->$k)) {
     //		 $rec[$k] = new Zend_Db_Expr('null');
     //	 } else {
     //		 $rec[$k] = $this->$k;
     //	 }
     // }
     // unset($rec['id']);
     $rec = array();
     foreach ($this->_data as $k => $v) {
         $rec[$k] = $v;
     }
     // @todo implement ts_vector
     // update vendors set fulltext = to_tsvector('english',name || ' ' || coalesce(description,''))
     if (isset($this->_properties['fulltext'])) {
         // Build Full Text
         // foreach ($this->_properties as $k=>$v) {
         //
         // }
     }
     if ($this->_data['id']) {
         // if ($this->_diff) Base_Diff::diff($this);
         SQL::update($this->_table, $rec, "id={$this->_data['id']}");
     } else {
         $this->_data['id'] = SQL::insert($this->_table, $rec);
         if (intval($this->_data['id']) == 0) {
             Radix::dump($this);
             Radix::dump(SQL::lastError());
             Radix::trace('Unexpected error saving: ' . get_class($this));
         }
         // if ($this->_diff) Base_Diff::diff($this);
     }
 }