Exemplo n.º 1
0
 protected static function get_attribs($id)
 {
     if (!$id || $id == 0) {
         Error::generate('debug', 'id is 0');
         return array();
     }
     $res = db_query("SELECT attrib FROM %s_data WHERE id='%d'", static::subGetClass(), $id);
     if (!$res || !($ret = db_get_list_of_results($res))) {
         Error::generate('debug', 'Could not query database in get_attribs');
         return array();
     }
     foreach ($ret as $key => $val) {
         $ret[$key] = intval($val[0]);
     }
     $ret = array_unique($ret, SORT_NUMERIC);
     return $ret;
 }
Exemplo n.º 2
0
 protected static function get_attrib($id, $attribid)
 {
     if (!is_int($attribid)) {
         $attribid = static::get_attrib_id($attribid);
     }
     $attribtype = static::get_attrib_type($attribid);
     $attribprops = static::get_attrib_props($attribid);
     switch ($attribtype) {
         case static::ATTRIB_TYPE_STRING:
             $datacol = 'stringdata';
             break;
         case static::ATTRIB_TYPE_INT:
             $datacol = 'intdata';
             break;
         default:
             Error::generate('debug', "Bad attribute type in get_attrib({$id}, {$attribstr}, {$val})");
             return false;
     }
     $res = db_query("SELECT %s FROM %s_data WHERE id='%d' AND attrib='%d'", $datacol, static::subGetClass(), $id, $attribid);
     if (!$res) {
         Error::generate('debug', 'No result, or could not query database in get_attrib');
         return false;
     }
     if ($attribprops & static::ATTRIB_PROP_UNIQUE) {
         $ret = db_get_result($res);
     } else {
         $ret = db_get_list_of_results($res);
     }
     if ($attribtype == static::ATTRIB_TYPE_INT && !is_array($ret)) {
         return intval($ret);
     } else {
         return $ret;
     }
 }