Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7df42c6
ignore files
val19116 Mar 30, 2016
7c49e02
auth class correction to functions.inc
Jul 6, 2016
58953ff
auth class correction to functions.inc
Jul 6, 2016
b828bd8
added trim() to aql insert and update methods
HarleyHWC Jul 28, 2016
763a975
added trim() to aql insert and update methods
HarleyHWC Jul 28, 2016
68d61b6
added trim() to aql insert and update methods
HarleyHWC Jul 28, 2016
2c38290
ignore files (reverted from commit 7df42c63e3bcdf7c4a697280a849b280d4…
Tkobrien Jul 28, 2016
fabf6e3
Merge remote-tracking branch 'origin/master'
Tkobrien Jul 28, 2016
925a829
Merge remote-tracking branch 'origin/master' (reverted from commit fa…
Tkobrien Jul 28, 2016
f812906
added trim() to aql insert and update methods
HarleyHWC Jul 28, 2016
7b9bc08
Merge branch 'master' of https://github.com/HotwireCommunications/skyphp
HarleyHWC Jul 28, 2016
bb3ca89
auth class correction to functions.inc (reverted from commit 58953ffd…
Tkobrien Jul 28, 2016
680bbf3
added trim() to aql insert and update methods
HarleyHWC Jul 28, 2016
42562e9
Merge branch 'master' of https://github.com/HotwireCommunications/skyphp
HarleyHWC Aug 9, 2016
8ce8c1d
re-enabled getRecords method
HarleyHWC Aug 12, 2016
eb06c0d
check to make sure class exists before executing
HarleyHWC Aug 15, 2016
2c426ef
new enhanced aql with trim and getRecords method
HarleyHWC Aug 15, 2016
1626299
Merge branch 'aqltrim'
Tkobrien Aug 19, 2016
95509d1
Merge branch 'new-aql'
Tkobrien Aug 19, 2016
a6c8039
adjustment to sql return and added ide
HarleyHWC Aug 23, 2016
2229558
Merge branch 'model-class'
Tkobrien Aug 23, 2016
26b81a7
modifications for new grid class and data handling
HarleyHWC Oct 26, 2016
9967f9c
Add Construct
Tkobrien Oct 28, 2016
5af5db9
1120 - Added video type mp4, mpeg to function getMimeTypes()
val19116 Dec 20, 2016
95f4200
Fixing the single quote problem in the URL
swigmoreHW Jan 16, 2018
a825f67
Added comment with my alternative code
swigmoreHW Jan 16, 2018
81e31ba
Merge pull request #1 from HotwireCommunications/SA-2513-Handle_Quote…
TerenceOB Feb 16, 2018
ea7417f
make changes on viewport of html5 file for responsive design
pritiraw Jan 10, 2019
50aa04a
Merge pull request #2 from HotwireCommunications/change-viewport-in-h…
TerenceOB Jan 10, 2019
2684dd3
Fixing missing favicon.ico
RafaelKis Mar 26, 2019
d77e519
Updated gitignore to exclude /.idea/
RafaelKis Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*#
.#*
*.DS_Store
/.idea/
2 changes: 1 addition & 1 deletion lib/Sky/Memcache/Transaction/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Type
/**
* Abstract constructor, child class should
*/
abstract public function __construct();
abstract public function __construct($key, $value, $duration = null);

/**
* Type should be either set | delete
Expand Down
2 changes: 1 addition & 1 deletion lib/Sky/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Page
/**
* @var string
*/
public $favicon = '/favicon.ico';
public $favicon = '/gethotwired-icon.png';

/**
* @var string
Expand Down
57 changes: 56 additions & 1 deletion lib/class/class.Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,11 @@ final public function __construct($data = null, $aql = null, $force_db = false,
list($aql, $force_db, $cnf) = $this->mapConstructArgs($aql, $force_db, $cnf);

# initialize this model
$r = new ReflectionClass($this);
$this->_model_path = dirname($r->getFilename());
$this->_model_name = get_class($this);
$this->getModelAql($aql)->makeProperties();
//$this->_token = $this->getToken();

# set if we're refreshing it
$this->_force_db = ($force_db || $_GET['refresh']);
Expand All @@ -338,6 +341,58 @@ final public function __construct($data = null, $aql = null, $force_db = false,
$this->checkConstructorData($data, $force_db);
}

/**
* returns sql query results
*
* @param array $a array of ids to return records on
*
*/
public function getRecords($a) {
$aql_array = null;
if(file_exists($this->_model_path.'/'.$this->_model_name.'.aql')){
$set_joins = ((isset($a['joins']))?false:true);
$set_columns = ((isset($a['columns']))?false:true);

$a['primary_id'] = $this->_primary_table.'.id';
$a['columns'][] = $this->_primary_table.".id as ".$this->_primary_table."_id";

$aql = file_get_contents($this->_model_path.'/'.$this->_model_name.'.aql');
$aql_array = aql2array($aql);
$tables = null; $ta = 'table';
//echo "<pre>".print_r($aql_array,true)."</pre>";
foreach($aql_array as $table => $array){
if($set_joins){
if(isset($array['on'])){
$a['joins'][] = "LEFT JOIN ".$array['table'].(($array['table']!=$table)?' '.$table:'')." ON ".$array['on'];
$ta = ((isset($array['as']))?'as':'table');
$a['columns'][] = $array[$ta].".id as ".$array[$ta]."_id";
$tables[] = $array[$ta];
}
}
if($set_columns){
foreach($array['fields'] as $key => $link){
if($this->_primary_table."_id"==$key) continue;
$a['columns'][] = $link." as ".(($key=='id')?$array[$ta]."_":'').$key;
}
}
}
}
$sql = "SELECT ".((!empty($a['columns']))?join(",",$a['columns']):'*')." FROM ".$this->_primary_table." ".((!empty($a['joins']))?join(" ",$a['joins']):'')." WHERE ".$a['primary_id']." IN ('".((!empty($a['ids']))?join("','",$a['ids']):'')."')".((isset($a['order_by']))?' ORDER BY '.$a['order_by']:" ORDER BY FIELD(".$a['primary_id'].", '".((!empty($a['ids']))?join("','",$a['ids']):'')."')");
//echo $sql;
$results = sql_array($sql);
//echo "<pre>".print_r($results, true)."</pre>";
foreach($results as $k=>$r){
//$results[$k][$this->_primary_table.'_id'] = $r[$this->_primary_table.'_id'];
$results[$k][$this->_primary_table.'_ide'] = encrypt($r[$this->_primary_table.'_id'],$this->_primary_table);
if(isset($tables)){
foreach($tables as $table){
$results[$k][$table.'_ide'] = encrypt($results[$k][$table.'_id'],$table);
}
}
}
// echo "<pre>".print_r($results, true)."</pre>";
return $results;
}

/**
* checks for a proper identifier, loads object if set runs construct()
Expand Down Expand Up @@ -1514,7 +1569,7 @@ public function getToken($id = null, $primary_table = null)
$id = decrypt($id, $primary_table);
}
$id = ($id) ?: $this->getID();

//echo "<pre>".print_r(array($primary_table,$id, self::_makeToken($id, $primary_table)),true)."</pre>";
return self::_makeToken($id, $primary_table);
}

Expand Down
18 changes: 15 additions & 3 deletions lib/class/class.aql.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@ public static function insert($table, $fields, $silent = false)
unset($fields['id']);
foreach ($fields as $k => $v) {
if ($v === null || $v === '') {
unset($fields[$k]);
unset($fields[$k]); continue;
}
$fields[$k] = trim($v);
}

if (!$fields) {
Expand Down Expand Up @@ -663,6 +664,8 @@ public function update($table, $fields, $identifier, $silent = false)
return false;
}

foreach ($fields as $k => $v) { $fields[$k] = trim($v); } //($v=='-0001-11-30'?NULL:trim($v)); }

$dbw = self::getMasterDB();
$result = $dbw->AutoExecute($table, $fields, 'UPDATE', 'id = ' . $id);
if ($result === true) {
Expand Down Expand Up @@ -1068,7 +1071,11 @@ private static function sql_result($arr, $settings, $db_conn = null)
$select_type = ($settings['select_type']) ?: 'sql';

$rs = array();
$microtime_start = microtime(true);
$r = $db_conn->Execute($arr[$select_type]);
if(class_exists('hwc_debug')){
hwc_debug::add_aql($arr[$select_type], number_format(microtime(true) - $microtime_start,3));
}

if ($r === false) {

Expand Down Expand Up @@ -1142,11 +1149,16 @@ private static function sql_result($arr, $settings, $db_conn = null)
);

if ($query) {
foreach ($query as $row) {
// new getRecords method
$ca = $s['constructor argument']; $p = new $m();
$arr = array('ids'=>array_map(function($a) use ($ca) { return $a[$ca]; },$query));
foreach($p->getRecords($arr) as $row){ $tmp[$k][]['_data'] = $row; }
// old query loop method
/* foreach ($query as $row) {
$arg = $row[$s['constructor argument']];
$o = Model::get($m, $arg, $sub_do_set);
$tmp[$k][] = ($object) ? $o : $o->dataToArray();
}
}*/
}
} else if (!$s['plural']) {
$arg = (int) $tmp[$s['constructor argument']];
Expand Down
Loading