Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating Dave objects to work with mongo

  • Loading branch information...
commit a0bb035a53d56dbde80051d7236c74b8811d9821 1 parent 0ce0579
@evantahler authored
View
5 API/Actions/examples/ObjectTest.php
@@ -71,11 +71,12 @@
// delete that user
$delete_resp = $OurUser->DELETE();
- if ($delete_resp == true){ $delete_resp = "OK";}
+ var_dump($delete_resp);
+ if ($delete_resp === true){$delete_resp = "OK";}
$TestResults["I_Delete_User"] = $delete_resp;
// how many users now?
- $TestResults["J_Original_User_Count"] = $UsersTable->count();
+ $TestResults["J_Final_User_Count"] = $UsersTable->count();
View
6 API/DB/DRIVERS/MONGO/DAVE.php
@@ -173,6 +173,7 @@ function _EDIT($Table, $VARS = null)
$VARS will be the params of the row to be added. VARS should include a key/value pair which includes either the primary key for the DB or one of the unique cols for the table. If unspecified, $PARAMS is used by default)
Settins is an array that can contain:
- $Settings["where_additions"]: Specific where statement. Array() for mongo. Example: Birtday = "1984-08-27"
+- $Settings["SQL_Override"]: normally, DAVE wants to only view a single row, and will error unless that row can be defined properly with unique values. set this true to bypass these checks, and view many rows at once
- $Settings["UpperLimit"]: used for LIMIT statement. Defaults to 100
- $Settings["LowerLimit"]: used for LIMIT statement. Defaults to 0
*/
@@ -186,7 +187,8 @@ function _VIEW($Table, $VARS = null, $Settings = null )
$where_additions = $Settings["where_additions"];
$UpperLimit = $Settings["UpperLimit"];
$LowerLimit = $Settings["LowerLimit"];
- // var_dump($VARS);
+ $SQL_Override = $Settings["SQL_Override"];
+
if ($UpperLimit == ""){$UpperLimit = $PARAMS["UpperLimit"];}
if ($LowerLimit == ""){$LowerLimit = $PARAMS["LowerLimit"];}
@@ -227,7 +229,7 @@ function _VIEW($Table, $VARS = null, $Settings = null )
}
$NeedAnd = true;
}
- if($NeedAnd == false)
+ if($NeedAnd == false && $SQL_Override != true)
{
$msg = "You have supplied none of the required parameters for this Action. At least one of the following is required: ";
foreach($UniqueVars as $var)
View
47 API/DB/DRIVERS/MONGO/DirectDBFunctions.php
@@ -17,6 +17,9 @@
- _CleanSessions()
- _CleanLog()
- _CleanCache()
+- _CountRowsInTable()
+- _FindDBMaxValue()
+- _FindDBMinValue()
***********************************************/
@@ -387,5 +390,49 @@ function _CleanCache()
return $resp;
}
+function _CountRowsInTable($Table)
+{
+ global $CONFIG, $DBOBJ;
+
+ if ($DBOBJ->GetStatus() != true){return false;}
+
+ $MongoDB = $DBOBJ->GetMongoDB();
+ $Colleciton = $MongoDB->$Table;
+ return $Colleciton->count();
+}
+
+function _FindDBMaxValue($Table, $col)
+{
+ global $CONFIG, $DBOBJ;
+
+ if ($DBOBJ->GetStatus() != true){return false;}
+
+ $MongoDB = $DBOBJ->GetMongoDB();
+ $Colleciton = $MongoDB->$Table;
+ $object = $Colleciton->find()->sort(array($col),-1)->limit(1);
+ if(!empty($object[$col])){
+ return $object[$col];
+ }
+ else
+ {
+ return false;
+ }
+}
+
+function _FindDBMinValue($Table, $col)
+{
+ global $CONFIG, $DBOBJ;
+
+ $MongoDB = $DBOBJ->GetMongoDB();
+ $Colleciton = $MongoDB->$Table;
+ $object = $Colleciton->find()->sort(array($col),1)->limit(1);
+ if(!empty($object[$col])){
+ return $object[$col];
+ }
+ else
+ {
+ return false;
+ }
+}
?>
View
3  API/Objects/_BASE.php
@@ -192,7 +192,8 @@ public function EDIT($params = null)
}
$resp = _EDIT($this->DaveTableObject->table(),$this->DATA);
$this->clean_data();
- return $resp[1][0];
+ if($resp[0] === true){ return $resp[1][0]; }
+ else{return $resp[1]; }
}
else{return true;}
}
Please sign in to comment.
Something went wrong with that request. Please try again.