Lines Matching refs:this

20         $this->_initialize();
49 $dsn = $this->getConf('default_dsn');
50 $dsn = $this->_expandTokens($dsn);
52 $this->_dsn = $dsn;
58 msg(sprintf($this->getLang('error_triples_nodriver'), $driver), -1);
63 $this->_db = new $driverClass($this->getConf('debug'));
66 if(!$this->_db->connect($dsn)) {
71 if(!$this->_db->isInitialized()) {
72 $this->_db->initializeDatabase();
86 return $this->_db->ci($a);
98 return $this->_ci($a).' = '.$this->_ci($b);
105 $this->_db->beginTransaction();
112 $this->_db->rollback();
124 $filters[]=$this->_cic($param, '?');
132 $query = $this->_db->prepare($sql);
139 msg(sprintf($this->getLang('error_triples_remove'),hsc($error[2])),-1);
156 $filters[]=$this->_cic($param,'?');
161 $scopeRestriction = ($this->getConf('scoped')? ' AND graph like "'.getNS($ID).'%"':"" );
163 if ($this->getConf('scoped'))
179 $query = $this->_db->prepare($sql);
187 msg(sprintf($this->getLang('error_triples_fetch'),hsc($error[2])),-1);
206 return $this->addTriples(array(array('subject'=>$subject, 'predicate'=>$predicate, 'object'=>$object)), $graph);
218 $query = $this->_db->prepare($sql);
222 $this->_db->beginTransaction();
231 msg(sprintf($this->getLang('error_triples_add'),hsc($error[2])),-1);
232 $this->_db->rollBack();
239 return $this->_db->commit();
250 $generator = new strata_sql_generator($this);
254 $query = $this->_db->prepare($sql);
263 msg(sprintf($this->getLang('error_triples_query'),hsc($error[2])),-1);
264 if($this->getConf('debug')) {
265 msg(sprintf($this->getLang('debug_sql'),hsc($sql)),-1);
266 msg(sprintf($this->getLang('debug_literals'), hsc(print_r($literals,1))),-1);
325 $result = $this->queryRelations($query);
359 $this->_triples = $triples;
360 $this->_db = $this->_triples->_db;
367 return $this->_triples->getLang($key);
374 return $this->_triples->_ci($a);
382 return $prefix.($this->_aliasCounter++);
399 if(empty($this->_variableLookup[$term['text']])) {
400 $this->_variableLookup[$term['text']] = $this->_alias('v');
403 return $this->_variableLookup[$term['text']];
406 if(empty($this->_literalLookup[$term['text']])) {
408 $this->_literalLookup[$term['text']] = $this->_alias('lit');
412 return $this->_literalLookup[$term['text']];
431 $id = $this->_alias('qv');
432 $conditions[] = $this->_ci('subject').' = '.$this->_ci(':'.$id);
433 $this->literals[$id] = $tp['subject']['text'];
438 $id = $this->_alias('qv');
439 $conditions[] = $this->_ci('predicate').' = '.$this->_ci(':'.$id);
440 $this->literals[$id] = $tp['predicate']['text'];
445 $id = $this->_alias('qv');
446 $conditions[] = $this->_ci('object').' = '.$this->_ci(':'.$id);
447 $this->literals[$id] = $tp['object']['text'];
451 if($this->_patternEquals($tp['subject'],$tp['predicate'])) {
452 $conditions[] = $this->_ci('subject').' = '.$this->_ci('predicate');
456 if($this->_patternEquals($tp['subject'],$tp['object'])) {
457 $conditions[] = $this->_ci('subject').' = '.$this->_ci('object');
461 if($this->_patternEquals($tp['predicate'],$tp['object'])) {
462 $conditions[] = $this->_ci('predicate').' = '.$this->_ci('object');
479 $list[] = 'subject AS '.$this->_name($tp['subject']);
482 if(!$this->_patternEquals($tp['subject'], $tp['predicate'])) {
483 $list[] = 'predicate AS '.$this->_name($tp['predicate']);
487 if(!$this->_patternEquals($tp['subject'], $tp['object']) && !$this->_patternEquals($tp['predicate'],$tp['object'])) {
488 $list[] = 'object AS '.$this->_name($tp['object']);
503 $terms[] = $this->_name($tp['subject']);
508 $terms[] = $this->_name($tp['predicate']);
513 $terms[] = $this->_name($tp['object']);
516 $scopeRestriction = ($this->_triples->getConf('scoped')? ' AND graph like "'.getNS($ID).'%"':"" );
518 'sql'=>'SELECT '.$this->_genPR($tp).' FROM '.helper_plugin_strata_triples::$readable.' WHERE '.$this->_genCond($tp).$scopeRestriction,
540 $intersect[] = '('.$this->_ci('r1.'.$c).' = '.$this->_ci('r2.'.$c).' OR r1.'.$c.' IS NULL OR r2.'.$c.' IS NULL)';
560 $gp1 = $this->_dispatch($query['lhs']);
561 $gp2 = $this->_dispatch($query['rhs']);
562 return $this->_trans_group($gp1, $gp2, 'LEFT OUTER JOIN');
569 $gp1 = $this->_dispatch($query['lhs']);
570 $gp2 = $this->_dispatch($query['rhs']);
571 return $this->_trans_group($gp1, $gp2, 'INNER JOIN');
578 $gp = $this->_dispatch($query['lhs']);
586 $lhs = $this->_name($f['lhs']);
588 $id = $this->_alias('qv');
590 $this->literals[$id] = $f['lhs']['text'];
595 $rhs = $this->_name($f['rhs']);
597 $id = $this->_alias('qv');
599 $this->literals[$id] = $f['rhs']['text'];
611 $filters[] = '( ' . $this->_ci($lhs) . ' '.$f['operator'].' ' . $this->_ci($rhs). ' )';
617 $filters[] = '( ' . $this->_triples->_db->castToNumber($lhs) . ' ' . $f['operator'] . ' ' . $this->_triples->_db->castToNumber($rhs) . ' )';
620 $filters[] = '( ' . $this->_ci($lhs) . ' '.$this->_db->stringCompare().' '. $this->_ci('(\'%\' || ' .$eh.$rhs.$et. ' || \'%\')') .$em. ')';
623 $filters[] = '( ' . $this->_ci($lhs) . ' NOT '.$this->_db->stringCompare().' '. $this->_ci('(\'%\' || ' . $eh.$rhs.$et. ' || \'%\')') .$em. ')';
626 $filters[] = '( ' . $this->_ci($lhs) . ' '.$this->_db->stringCompare().' ' .$this->_ci('('. $eh.$rhs.$et . ' || \'%\')').$em. ')';
629 $filters[] = '( ' . $this->_ci($lhs) . ' NOT '.$this->_db->stringCompare().' ' .$this->_ci('('. $eh.$rhs.$et . ' || \'%\')').$em. ')';
632 $filters[] = '( ' . $this->_ci($lhs) . ' '.$this->_db->stringCompare().' '.$this->_ci('(\'%\' || ' . $eh.$rhs.$et. ')') .$em. ')';
635 $filters[] = '( ' . $this->_ci($lhs) . ' NOT '.$this->_db->stringCompare().' '.$this->_ci('(\'%\' || ' . $eh.$rhs.$et. ')') .$em. ')';
654 $gp1 = $this->_dispatch($query['lhs']);
655 $gp2 = $this->_dispatch($query['rhs']);
663 $terms[] = '('.$this->_ci('r1.'.$c).' = '.$this->_ci('r2.'.$c).')';
683 $gp1 = $this->_dispatch($query['lhs']);
684 $gp2 = $this->_dispatch($query['rhs']);
688 $gp1x = $this->_dispatch($query['lhs']);
689 $gp2x = $this->_dispatch($query['rhs']);
724 $gp = $this->_dispatch($query['group']);
736 // we do this by combining ordering and sorting information as follows:
768 $name = $this->_name(array('type'=>'variable', 'text'=>$v));
772 $this->grouped[$name] = $v;
780 $name = $this->_name(array('type'=>'variable','text'=>$v));
787 $this->projected[$name] = $v;
791 $this->grouped[$name] = $v;
797 $name = $this->_name(array('type'=>'variable', 'text'=>$v));
798 $alias = $this->_alias('c');
805 $name = $this->_name(array('type'=>'variable','text'=>$o['variable']));
806 $orderTerms = $this->_db->orderBy($name);
808 $a = $this->_alias('o');
833 return $this->_trans_select($query);
835 return $this->_trans_union($query);
837 return $this->_trans_minus($query);
839 return $this->_trans_opt($query);
841 return $this->_trans_filter($query);
843 return $this->_trans_tp($query);
845 return $this->_trans_and($query);
847 msg(sprintf($this->getLang('error_triples_node'),hsc($query['type'])),-1);
856 $q = $this->_dispatch($query);
857 return array($q['sql'], $this->literals, $this->projected, $this->grouped);
868 $this->data = $pdostatement;
871 $this->closed = false;
872 $this->id = 0;
875 $this->projection = $projection;
878 $this->next();
882 return $this->row;
886 return $this->id;
891 $this->row = $this->data->fetch(PDO::FETCH_ASSOC);
893 if($this->row) {
897 foreach($this->projection as $alias=>$field) {
898 $row[$field] = $this->row[$alias] != null ? array($this->row[$alias]) : array();
900 $this->row = $row;
903 $this->id++;
909 // this is a good safety net)
910 if(!$this->valid()) {
911 $this->closeCursor();
920 return $this->row != null;
924 * Closes this result set.
927 if(!$this->closed) {
928 $this->data->closeCursor();
929 $this->closed = true;
941 $this->data = $relations;
944 $this->closed = false;
945 $this->valid = true;
946 $this->item = null;
947 $this->subject = null;
950 list($this->__subject, $this->__predicate, $this->__object) = $projection;
953 $this->next();
957 return $this->item;
961 return $this->subject;
965 if(!$this->data->valid()) {
966 $this->valid = false;
971 $peekRow = $this->data->current();
974 $this->item = array();
975 $this->subject = $peekRow[$this->__subject][0];
979 while($this->data->valid() && $peekRow[$this->__subject][0] == $this->subject) {
980 $p = $peekRow[$this->__predicate][0];
981 $o = $peekRow[$this->__object][0];
982 if(!isset($this->item[$p])) $this->item[$p] = array();
983 $this->item[$p][] = $o;
985 $this->data->next();
986 $peekRow = $this->data->current();
989 return $this->item;
997 return $this->valid;
1001 * Closes this result set.
1004 if(!$this->closed) {
1005 $this->data->closeCursor();
1006 $this->closed = true;
1018 $this->data = $pdostatement;
1021 $this->closed = false;
1022 $this->valid = true;
1023 $this->item = null;
1024 $this->subject = 0;
1026 $this->groupKey = $grouped;
1027 $this->projection = $projection;
1030 $this->peekRow = $this->data->fetch(PDO::FETCH_ASSOC);
1031 $this->next();
1035 return $this->item;
1039 return $this->subject;
1044 foreach($this->groupKey as $alias=>$field) {
1055 if($this->peekRow == null) {
1056 $this->valid = false;
1061 $key = $this->extractKey($this->peekRow);
1064 $this->subject++;
1065 $this->item = array();
1069 while($this->peekRow != null && $this->keyCheck($key,$this->extractKey($this->peekRow))) {
1070 foreach($this->projection as $alias=>$field) {
1071 if(in_array($field, $this->groupKey)) {
1073 $this->item[$field] = $key[$field]!=null ? array($key[$field]) : array();
1076 if(empty($this->item[$field])) {
1077 $this->item[$field] = array();
1081 if($this->peekRow[$alias] != null) {
1082 $this->item[$field][] = $this->peekRow[$alias];
1087 $this->peekRow = $this->data->fetch(PDO::FETCH_ASSOC);
1090 if($this->peekRow == null) {
1091 $this->closeCursor();
1094 return $this->item;
1102 return $this->valid;
1106 * Closes this result set.
1109 if(!$this->closed) {
1110 $this->data->closeCursor();
1111 $this->closed = true;