Select Where In Join
I want to get results from ids i already know. This is my attempt(pseudo):
SELECT * FROM main LEFT JOIN child WHERE main.id IN("1,2,3,4") ON main.id
= child.main_id
How to get the childs from main by known ids from WHERE IN?
thx for help
Thursday, 12 September 2013
split JSON data from PHP to three arrays in JavaScript
split JSON data from PHP to three arrays in JavaScript
I am passing values from PHP Script to JS using JSON encode.
$arr=array('X'=>$X,'Y'=>$Y,'par'=>$par);
echo json_encode($arr);
Which produces
{"X":
["-0.9537121038646844","-0.9537121038646844","-0.9537121038646844","0.9537121038646843",""],
"Y":
["-0.9537121038646844","-0.7799936811949519","-0.5533396521383813","-0.37962122946864896",null],
"par":
["0.009811016749950838","0.005007306592216437","5.058030686503405E-4","9.451402320405391E-4",null]}
In the javascript, I used the following command
{
$.post("plot.php",param,function(data){dataType:"json";console.log(data);Var
X1=data.X;});
}
But I am not able to obtain the values of X alone. I tried few suggestions
from similar threads, but none of them did the trick.I need the three
arrays, X,Y and Par to be used in JS.
I am passing values from PHP Script to JS using JSON encode.
$arr=array('X'=>$X,'Y'=>$Y,'par'=>$par);
echo json_encode($arr);
Which produces
{"X":
["-0.9537121038646844","-0.9537121038646844","-0.9537121038646844","0.9537121038646843",""],
"Y":
["-0.9537121038646844","-0.7799936811949519","-0.5533396521383813","-0.37962122946864896",null],
"par":
["0.009811016749950838","0.005007306592216437","5.058030686503405E-4","9.451402320405391E-4",null]}
In the javascript, I used the following command
{
$.post("plot.php",param,function(data){dataType:"json";console.log(data);Var
X1=data.X;});
}
But I am not able to obtain the values of X alone. I tried few suggestions
from similar threads, but none of them did the trick.I need the three
arrays, X,Y and Par to be used in JS.
Index Not working well in mysql
Index Not working well in mysql
I have a a query like this :
SELECT SQL_NO_CACHE u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
explain :
SIMPLE privatemessagereceiver ref pmrpmid,pmrtouserid pmrtouserid 4
**const** 3116 Using where; Using filesort
IT workes well on index and it takes only 0.0006 sec to execute
but when I use that query like this :
SELECT SQL_NO_CACHE result.*
FROM (
SELECT u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
) as result
explain :
PRIMARY <derived2> ALL NULL NULL NULL NULL 3117
2 DERIVED privatemessagereceiver ALL pmrtouserid pmrtouserid 4
7054 Using where; Using filesort
it takes 1.1 sec to execute !
============================================================== It seem
that the 2nd query do not user index and as you can see const is not
defined . Also I used Use Index And Force Index , but not working ...
where is the problem and how can I solve ?
I have a a query like this :
SELECT SQL_NO_CACHE u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
explain :
SIMPLE privatemessagereceiver ref pmrpmid,pmrtouserid pmrtouserid 4
**const** 3116 Using where; Using filesort
IT workes well on index and it takes only 0.0006 sec to execute
but when I use that query like this :
SELECT SQL_NO_CACHE result.*
FROM (
SELECT u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
) as result
explain :
PRIMARY <derived2> ALL NULL NULL NULL NULL 3117
2 DERIVED privatemessagereceiver ALL pmrtouserid pmrtouserid 4
7054 Using where; Using filesort
it takes 1.1 sec to execute !
============================================================== It seem
that the 2nd query do not user index and as you can see const is not
defined . Also I used Use Index And Force Index , but not working ...
where is the problem and how can I solve ?
Thread-safety in C#
Thread-safety in C#
I have currently been assigned a project that was implemented couple of
years ago in C#. It consists of frames and some excel-files extraction,
but the problem is that this project is extremly broken/outdated and I
have to change some functionalities and add some new feature.
There are some libraries that are supported only after .NET framework 3.0
that I need to use in the new features,and the framework that the current
project was built on is 2.0 or less,so changing the framework raised some
thread safety problems.
Between two partial classes for example which are the design file code and
the backend code trying to change one label's value raises an error saying
that I can not edit something that is being used at the moment... I used
delegates for one of the labels, and it worked fine..then the other
textbox raised another error.. So is there an option to encapsulate the
whole thing and apply thread safety to the whole code without having to
follow each line where the error happens?
Regards
I have currently been assigned a project that was implemented couple of
years ago in C#. It consists of frames and some excel-files extraction,
but the problem is that this project is extremly broken/outdated and I
have to change some functionalities and add some new feature.
There are some libraries that are supported only after .NET framework 3.0
that I need to use in the new features,and the framework that the current
project was built on is 2.0 or less,so changing the framework raised some
thread safety problems.
Between two partial classes for example which are the design file code and
the backend code trying to change one label's value raises an error saying
that I can not edit something that is being used at the moment... I used
delegates for one of the labels, and it worked fine..then the other
textbox raised another error.. So is there an option to encapsulate the
whole thing and apply thread safety to the whole code without having to
follow each line where the error happens?
Regards
Wednesday, 11 September 2013
How to move CSS navbar elements to the right?
How to move CSS navbar elements to the right?
for an online course I was taking I created a web app through heroku
here is the site
http://is.gd/fMJN8f
In the top I have a navigation bar with elements for home, about, faq,
contact, login and register
I would like to move the login and register elements to the right of the
navigation bar so the login drop-down menu looks nicer
here is the code I tried
<div class = "navbar navbar-inverse navbar-fixed-top">
<div class = "navbar-inner">
<div class = "container">
<button type = "button" class = "btn btn-navbar" data-toggle =
"collapse" data-target = ".nav-collapse">
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
</button>
<a class = "brand" href = "#"><span class =
"SportMem-sport">Sport</span><span class =
"SportMem-mem">Mem</span></a>
<div class = "nav-collapse collapse">
<ul class = "nav">
<li class = "active"><a href = "#">Home</a></li>
<li><a href = "/about">About</a></li>
<li><a href = "/faq">FAQs</a></li>
<li><a href = "/contact">Contact</a></li>
<li class = "login">
<a id = "login-start" href = "#">
Login<span></span>
</a>
<div id = "login-form">
<form>
<fieldset id = "inputs">
<input id = "username" type = "email" name = "Email"
placeholder = "Email Address" required>
<input id = "password" type = "password" name = "Password"
placeholder = "Password" required>
</fieldset>
<fieldset id = "actions">
<input type = "submit" id = "submit" value = "Log-in">
<label><input type = "checkbox" checked = "checked"> Keep me
logged-on</label>
</fieldset>
</form>
</div>
</li>
<li class = "register.html"><a href = "#register">Register</a></li>
</ul>
</div>
</div>
</div>
i tried floating the elements to the right among others but nothing I've
tried worked
Could someone please find me a solution?
Help is greatly appreciated
for an online course I was taking I created a web app through heroku
here is the site
http://is.gd/fMJN8f
In the top I have a navigation bar with elements for home, about, faq,
contact, login and register
I would like to move the login and register elements to the right of the
navigation bar so the login drop-down menu looks nicer
here is the code I tried
<div class = "navbar navbar-inverse navbar-fixed-top">
<div class = "navbar-inner">
<div class = "container">
<button type = "button" class = "btn btn-navbar" data-toggle =
"collapse" data-target = ".nav-collapse">
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
</button>
<a class = "brand" href = "#"><span class =
"SportMem-sport">Sport</span><span class =
"SportMem-mem">Mem</span></a>
<div class = "nav-collapse collapse">
<ul class = "nav">
<li class = "active"><a href = "#">Home</a></li>
<li><a href = "/about">About</a></li>
<li><a href = "/faq">FAQs</a></li>
<li><a href = "/contact">Contact</a></li>
<li class = "login">
<a id = "login-start" href = "#">
Login<span></span>
</a>
<div id = "login-form">
<form>
<fieldset id = "inputs">
<input id = "username" type = "email" name = "Email"
placeholder = "Email Address" required>
<input id = "password" type = "password" name = "Password"
placeholder = "Password" required>
</fieldset>
<fieldset id = "actions">
<input type = "submit" id = "submit" value = "Log-in">
<label><input type = "checkbox" checked = "checked"> Keep me
logged-on</label>
</fieldset>
</form>
</div>
</li>
<li class = "register.html"><a href = "#register">Register</a></li>
</ul>
</div>
</div>
</div>
i tried floating the elements to the right among others but nothing I've
tried worked
Could someone please find me a solution?
Help is greatly appreciated
Validation of a geometry in WKT format
Validation of a geometry in WKT format
I am new to GIS area and I need to validate a geometry in WKT format in
java, to check whether a simple polygon is a closed loop, i.e the start
and end points of the vertices should be the same. I am currently using
jGeometry class of oracle spatial(com.oracle.sdoapi), get the first and
last vertices and comparing them. also, i am using getType() method to
check whether it is a simple polygon or not. The following is the piece of
code that am using:
WKT wkt = new WKT();
JGeometry geometry = wkt.toJGeometry(wkt.getBytes());
double[] d1 = geometry.getFirstPoint();
double[] d2 = geometry.getLastPoint();
if(!jGeometry.getType() == jGeometry.GTYPE_POLYGON){
//error message for other geometries
}
Is there any simple way of doing this or is there any API available? I
dont want to reinvent the wheel, if it is already done and simple to use.
Thanks!
I am new to GIS area and I need to validate a geometry in WKT format in
java, to check whether a simple polygon is a closed loop, i.e the start
and end points of the vertices should be the same. I am currently using
jGeometry class of oracle spatial(com.oracle.sdoapi), get the first and
last vertices and comparing them. also, i am using getType() method to
check whether it is a simple polygon or not. The following is the piece of
code that am using:
WKT wkt = new WKT();
JGeometry geometry = wkt.toJGeometry(wkt.getBytes());
double[] d1 = geometry.getFirstPoint();
double[] d2 = geometry.getLastPoint();
if(!jGeometry.getType() == jGeometry.GTYPE_POLYGON){
//error message for other geometries
}
Is there any simple way of doing this or is there any API available? I
dont want to reinvent the wheel, if it is already done and simple to use.
Thanks!
What more does the code need to delete a node from a linked list successfully?
What more does the code need to delete a node from a linked list
successfully?
I want to delete a given node from a linked list by the node's index
number (serial number). So what I tried to do in my function is that,
first I have taken the user input of the index number. Then I used two
node type pointers temp and current. I started traversing the list with
current and when the index number of the node matches with the user input,
I tried to delete the node. So far it is correct. I am facing problem with
the deletion logic. Here is the code I tried:
void delete_node(struct node **start,int index_no)
{
int counter=0;
struct node *temp, *current;
temp=(struct node *)malloc(sizeof(struct node));
current=(struct node *)malloc(sizeof(struct node));
current=*start;
while(current->next!=NULL)
{
counter++;
if(counter==index_no)
{
temp= current->next;
free(current);
/*I guess some code is missing here. Help me finding the logic.*/
}
else
{
printf("\n The index number is invalid!!");
}
}
}
The commented portion lacks the deletion logic. Also, I have a feeling
that this code is not space and time-efficient. If it is so, please
suggest to a way to make it more compact.
successfully?
I want to delete a given node from a linked list by the node's index
number (serial number). So what I tried to do in my function is that,
first I have taken the user input of the index number. Then I used two
node type pointers temp and current. I started traversing the list with
current and when the index number of the node matches with the user input,
I tried to delete the node. So far it is correct. I am facing problem with
the deletion logic. Here is the code I tried:
void delete_node(struct node **start,int index_no)
{
int counter=0;
struct node *temp, *current;
temp=(struct node *)malloc(sizeof(struct node));
current=(struct node *)malloc(sizeof(struct node));
current=*start;
while(current->next!=NULL)
{
counter++;
if(counter==index_no)
{
temp= current->next;
free(current);
/*I guess some code is missing here. Help me finding the logic.*/
}
else
{
printf("\n The index number is invalid!!");
}
}
}
The commented portion lacks the deletion logic. Also, I have a feeling
that this code is not space and time-efficient. If it is so, please
suggest to a way to make it more compact.
Subscribe to:
Posts (Atom)