GIT.Harvie.CZ
/
mirrors
/
Kyberia-bloodline.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
de9b503
)
set_synapse fix
author
niekt0
<niekt0@kyberia.cz>
Sun, 27 Mar 2011 22:02:04 +0000
(
00:02
+0200)
committer
niekt0
<niekt0@kyberia.cz>
Sun, 27 Mar 2011 22:02:04 +0000
(
00:02
+0200)
wwwroot/backend/mysql/backend.inc
patch
|
blob
|
blame
|
history
diff --git
a/wwwroot/backend/mysql/backend.inc
b/wwwroot/backend/mysql/backend.inc
index a92deeae52ef3106a845110a95ef22fe29c07961..6bc454be76d4dc8ed31c903b54950ce7071b2596 100644
(file)
--- a/
wwwroot/backend/mysql/backend.inc
+++ b/
wwwroot/backend/mysql/backend.inc
@@
-341,19
+341,24
@@
function getKNeurons($user_id,$interval) {
return $k_array;
}
return $k_array;
}
-//
Set synapse weight,
+//
setSynapse
-// Se
cure
-//
Returns true on sucess, otherwise false
-
-//
XXX TODO
+// Se
t synapse weight.
+//
If synapse does not exists, create a new one.
+// Secure.
+//
Returns true on sucess, otherwise false.
function setSynapse($params){
global $db,$node,$error,$error_messages;
function setSynapse($params){
global $db,$node,$error,$error_messages;
- if ((!is_numeric($params['src'])) or (!is_numeric($params['dst'])) or (!is_numeric($params['weight']))) {
+ // security check
+ if ((!is_numeric($params['src']))
+ or (!is_numeric($params['dst']))
+ or (!is_numeric($params['weight']))) {
+
return false;
}
return false;
}
+
$src=$params['src'];
$dst=$params['dst'];
$weight=$params['weight'];
$src=$params['src'];
$dst=$params['dst'];
$weight=$params['weight'];
@@
-361,15
+366,15
@@
function setSynapse($params){
// if already exists
$q="select src from neurons where dst ='$dst' and src = '$src'";
$set=$db->query($q);
// if already exists
$q="select src from neurons where dst ='$dst' and src = '$src'";
$set=$db->query($q);
-
$set->next();
$isrc=$set->getString('src');
$set->next();
$isrc=$set->getString('src');
- if ( $set ) {
+
+ if ( $isrc ) {
$q="update neurons set synapse_weight='$synapse_weight'
where dst = '$dst' and src = '$src'";
} else {
// FIXME no vector set
$q="update neurons set synapse_weight='$synapse_weight'
where dst = '$dst' and src = '$src'";
} else {
// FIXME no vector set
- $q="insert into neurons values('$
synapse_
weight','$dst','$src',0,'synapse',
+ $q="insert into neurons values('$weight','$dst','$src',0,'synapse',
CURRENT_TIMESTAMP(),now(),NULL,$src)";
}
$set=$db->query($q);
CURRENT_TIMESTAMP(),now(),NULL,$src)";
}
$set=$db->query($q);
This page took
0.11223 seconds
and
4
git commands to generate.