예제 #1
0
 private function MontaWhere($num_fields, $fields, $values)
 {
     $sql = null;
     $montasql = new MontaSQL($this->object);
     $pks = $montasql->GetPKs();
     $qpk = 0;
     if ($pks == "" || $pks == null) {
         throw new Exception("Ocorreu um erro ao tentar buscar PKs da tabela", 404);
     }
     for ($i = 0; $i < $num_fields; $i++) {
         if (@$fields[$i] == @$pks[$i]) {
             $qpk++;
         }
     }
     if ($qpk == 0) {
         throw new Exception("PK não informada", 404);
     }
     for ($i = 0; $i < $num_fields; $i++) {
         if ($i == 0) {
             $sql .= " WHERE " . $fields[$i] . " = " . $values[$i][0];
         } else {
             if ($i == $num_fields - 1) {
                 $sql .= "   AND " . $fields[$i] . " = " . $values[$i][0];
             } else {
                 $sql .= "   AND " . $fields[$i] . " = " . $values[$i][0];
             }
         }
     }
     return $sql;
 }
예제 #2
0
 private function MontaUpdate($num_fields, $fields, $values)
 {
     $sql = null;
     $montasql = new MontaSQL($this->object);
     $pks = $montasql->GetPKs();
     $qpk = count($pks);
     for ($i = 0; $i < $num_fields; $i++) {
         if (@$fields[$i] != @$pks[$i]) {
             if ($i < $num_fields - 1) {
                 $sql .= $fields[$i] . " = " . $values[$i][0] . ", ";
             } else {
                 if ($i == $num_fields - 1) {
                     $sql .= "       " . $fields[$i] . " = " . $values[$i][0];
                 } else {
                     $sql .= "       " . $fields[$i] . " = " . $values[$i][0] . ", ";
                 }
             }
         }
     }
     return $sql;
 }
예제 #3
0
 private function MontaWherePK($num_fields, $fields, $values)
 {
     $sql = null;
     $montasql = new MontaSQL($this->object);
     $pks = $montasql->GetPKs();
     $qpk = count($pks);
     for ($i = 0; $i < $num_fields; $i++) {
         if (@$fields[$i] == @$pks[$i]) {
             if ($i < $num_fields - 1) {
                 $sql .= " WHERE " . $fields[$i] . " = " . $values[$i][0];
             } else {
                 if ($i == $num_fields - 1) {
                     $sql .= "   AND " . $fields[$i] . " = " . $values[$i][0];
                 } else {
                     $sql .= "   AND " . $fields[$i] . " = " . $values[$i][0];
                 }
             }
         }
     }
     if ($sql == null) {
         throw new Exception("PK não informada", 404);
     }
     return $sql;
 }