Example #1
0
 public function render($view, $options = array())
 {
     if ($this->provider === null) {
         nf_error(11);
         return;
     }
     $this->total = -1;
     $this->rendered = 0;
     $this->provider->begin();
     while ($obj = $this->provider->getNext()) {
         $filter = $this->filter;
         if ($filter !== null && !$filter($obj)) {
             continue;
         }
         $this->total++;
         if ($this->perpage != 0) {
             if ($this->total < ($this->page - 1) * $this->perpage) {
                 continue;
             }
             if ($this->rendered >= $this->perpage) {
                 break;
             }
         }
         $this->renderOne($view, $obj, $options);
         $this->rendered++;
     }
     $this->total = $this->provider->count();
     $this->provider->end();
     if ($this->perpage != 0 && $this->renderPaging) {
         $this->renderPagingButtons();
     }
 }
Example #2
0
 public static function findPrimaryKey()
 {
     $tablename = static::tablename();
     $res = nf_sql_query('SHOW KEYS FROM ' . static::queryTablename($tablename) . ' WHERE Key_name = \'PRIMARY\'');
     $row = $res->fetch_assoc();
     if ($row !== null) {
         return $row['Column_name'];
     }
     nf_error(9, $tablename);
     return false;
 }
Example #3
0
/**
 * Perform a query on the SQL database.
 */
function nf_sql_query($query)
{
    global $nf_sql;
    $ret = $nf_sql->query($query);
    if ($ret === false) {
        nf_error(10, nf_t('Error was:') . ' ' . $nf_sql->error . ' - ' . nf_t('Query was:') . ' ' . $query);
    }
    return $ret;
}