Permalink
Browse files

Add comments to underTemplate class file.

  • Loading branch information...
1 parent 22c0bd7 commit c0b968ecfcd3109383b7147ed477936dfc67046c Abdullah Almehmadi committed Aug 10, 2011
Showing with 205 additions and 15 deletions.
  1. +16 −3 src/multi/underQL.php
  2. +50 −6 src/single/underQL.php
  3. +139 −6 src/template/underTemplate.php
View
@@ -861,7 +861,7 @@ public function __get( $key )
the non-numerical fields becuase we need this array to help us when we calling
the quote method to add a single quotes.
*/
- public function readFields( )
+ private function readFields( )
{
global $UNDERQL;
@@ -951,6 +951,12 @@ public function getBy($fname,$ival)
}
+ /*
+ To insert or update data that are comming from array.
+ $op : if 'i' then, insert, otherwise, update.
+ $value : array of values.
+ $extra : used with update if you would like to put a condition.
+ */
private function opFromArray($op,$values,$extra = null)
{
@@ -965,8 +971,6 @@ private function opFromArray($op,$values,$extra = null)
{
if(in_array($key,$this->table_fields_names[$this->getTableName()]))
$this->$key = $val;
-
- echo $key.'<br />';
}
if(@count($this->data_buffer) == 0)
@@ -980,11 +984,20 @@ private function opFromArray($op,$values,$extra = null)
return $this->update($extra);
}
+ /*
+ To insert data that are comming from array.
+ $value : array of values.
+ */
public function insertFromArray($values)
{
return $this->opFromArray('i',$values);
}
+ /*
+ To update data that are comming from array.
+ $value : array of values.
+ $extra : used with update if you would like to put a condition.
+ */
public function updateFromArray($values,$extra = null)
{
return $this->opFromArray('u',$values,$extra);
View
@@ -470,7 +470,6 @@ function uql_plugin_toJSON($that,$args)
define ('UQL_RULE_OK',0xE4);
define ('UQL_RULE_FAIL',0xE5); // when rule fail of all rules
-
class UQLRule
{
private $table_name;
@@ -1301,7 +1300,7 @@ public function __get( $key )
the non-numerical fields becuase we need this array to help us when we calling
the quote method to add a single quotes.
*/
- public function readFields( )
+ private function readFields( )
{
global $UNDERQL;
@@ -1326,6 +1325,12 @@ public function readFields( )
}
}
+ public function isPluginExist($plugin)
+ {
+ global $UNDERQL;
+ return function_exists($UNDERQL['plugin']['api_prefix'].$plugin);
+ }
+
/*
Used to apply plugin.
$func : plugin name.
@@ -1336,10 +1341,11 @@ public function __call($func,$args)
{
global $UNDERQL;
- $plugin_callback = $UNDERQL['plugin']['api_prefix'].$func;
-
- if(function_exists($plugin_callback))
- return $plugin_callback($this,$args);
+ if($this->isPluginExist($func))
+ {
+ $plugin_callback = $UNDERQL['plugin']['api_prefix'].$func;
+ return $plugin_callback($this,$args);
+ }
return UQL_PLUGIN_RETURN;
@@ -1383,6 +1389,43 @@ public function getBy($fname,$ival)
return true;
}
+
+ private function opFromArray($op,$values,$extra = null)
+ {
+
+ if(!is_array($values))
+ return false;
+
+ $val_counts = @count($values);
+ if($val_counts == 0)
+ return false;
+ // var_dump($this->table_fields_names);
+ foreach($values as $key => $val)
+ {
+ if(in_array($key,$this->table_fields_names[$this->getTableName()]))
+ $this->$key = $val;
+ }
+
+ if(@count($this->data_buffer) == 0)
+ return false;
+
+ if(!$this->isRulesPassed())
+ return $this->getRuleError();
+ if(strcmp(strtolower($op),'i') == 0)
+ return $this->insert();
+ else
+ return $this->update($extra);
+ }
+
+ public function insertFromArray($values)
+ {
+ return $this->opFromArray('i',$values);
+ }
+
+ public function updateFromArray($values,$extra = null)
+ {
+ return $this->opFromArray('u',$values,$extra);
+ }
/*
Free the database results and close the database.
*/
@@ -1401,4 +1444,5 @@ public function finish( )
$_ = new underQL( );
$underQL = &$_;
+
?>
Oops, something went wrong.

0 comments on commit c0b968e

Please sign in to comment.