Ways of importing data from databases
I'm creating a web app which displays datas contained in a database.
I wrote the code and the app works, at least whith basic functions.
I'm already thinking about the future and that's why I'm asking for your help.
In case I will change the name of database's columns or maybe adding some new columns I will have to modify every single page of my code, if I want them to be shown in my web app.
For this reason I'd like to ask you if it is possible to write the columns name I want to import in a text file and then call this file to define which database's columns should be displayed on the net.
I'm attaching you the code I have write now so that you can understand better the part I want to change (which is the one of the 'while loop').
<html>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div id="holder">
<h1><?php echo "<font face=verdana size=30 color=#036>CAMBIO AMINOACIDICO</font>";?></h1></div>
<br>
<div id="sidebar" style="width:90%" class="sidebar">
<A HREF="ricerca_var_AA.php" class="w2-bar-item w2-button">NUOVA RICERCA</A>
  |
<A HREF="ricerca_paziente.php" class="w2-bar-item w2-button">RICERCA PER PAZIENTE</A>
  |
<A HREF="ricerca_gene.php" class="w2-bar-item w2-button">RICERCA PER GENE</A>
  |
<A HREF="ricerca_var.php" class="w2-bar-item w2-button">RICERCA PER VARIANTE</A>
  |
<A HREF="home.php" class="w2-bar-item w2-button">HOME</A>
<P> </P>
</div>
<div class="container">
<?php
$conn= mysql_connect("loc", "db", "pss");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("variant_db", $conn);
if(isset($_POST["vai"])){
$aa=$_POST["aa"];
}
echo "Verranno visualizzate le varianti per il seguente cambio di aminoacido:'<b>$aa</b>'.";?>
<br /><br />
<?php
$sql="SELECT A.AAchange, V.dnaCode, V.Chr, A.Start, A.End, A.Alt, A.Ref, V.zygosity, A.gene FROM annotazioni as A JOIN variante as V ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE A.AAchange='$aa'";
$result_dna = mysql_query($sql, $conn) or die(mysql_error());
if(mysql_num_rows($result_dna) == 0)
{
echo "<br>La ricerca non ha prodotto alcun risultato!<br>";
echo"<b>Effettuare una nuova ricerca.</b><br><br>";
}else
{?>
<div class="row">
<div class="col-mid-8 col-mid-offset-2">
<table id="table_var" "width=100%" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>AAchange</th>
<th>dnaCode</th>
<th>Chr</th>
<th>Start</th>
<th>End</th>
<th>Alt</th>
<th>Ref</th>
<th>Zigosity</th>
<th>Gene</th>
</tr>
</thead>
<tbody>
<?PHP
while ($record_dna=mysql_fetch_array($result_dna)){
echo '
<tr>
<td>'.$record_dna['AAchange'].'</td>
<td>'.$record_dna['dnaCode'].'</td>
<td>'.$record_dna['Chr'].'</td>
<td>'.$record_dna['Start'].'</td>
<td>'.$record_dna['End'].'</td>
<td>'.$record_dna['Alt'].'</td>
<td>'.$record_dna['Ref'].'</td>
<td>'.$record_dna['zygosity'].'</td>
<td>'.$record_dna['gene'].'</td>
</tr>
';
}
};?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"> </script>
<script type="text/javascript" src="js/ddtf.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" >
$('#table_var').ddTableFilter();
</script>
</body>
</html>
php database web-applications
add a comment |
I'm creating a web app which displays datas contained in a database.
I wrote the code and the app works, at least whith basic functions.
I'm already thinking about the future and that's why I'm asking for your help.
In case I will change the name of database's columns or maybe adding some new columns I will have to modify every single page of my code, if I want them to be shown in my web app.
For this reason I'd like to ask you if it is possible to write the columns name I want to import in a text file and then call this file to define which database's columns should be displayed on the net.
I'm attaching you the code I have write now so that you can understand better the part I want to change (which is the one of the 'while loop').
<html>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div id="holder">
<h1><?php echo "<font face=verdana size=30 color=#036>CAMBIO AMINOACIDICO</font>";?></h1></div>
<br>
<div id="sidebar" style="width:90%" class="sidebar">
<A HREF="ricerca_var_AA.php" class="w2-bar-item w2-button">NUOVA RICERCA</A>
  |
<A HREF="ricerca_paziente.php" class="w2-bar-item w2-button">RICERCA PER PAZIENTE</A>
  |
<A HREF="ricerca_gene.php" class="w2-bar-item w2-button">RICERCA PER GENE</A>
  |
<A HREF="ricerca_var.php" class="w2-bar-item w2-button">RICERCA PER VARIANTE</A>
  |
<A HREF="home.php" class="w2-bar-item w2-button">HOME</A>
<P> </P>
</div>
<div class="container">
<?php
$conn= mysql_connect("loc", "db", "pss");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("variant_db", $conn);
if(isset($_POST["vai"])){
$aa=$_POST["aa"];
}
echo "Verranno visualizzate le varianti per il seguente cambio di aminoacido:'<b>$aa</b>'.";?>
<br /><br />
<?php
$sql="SELECT A.AAchange, V.dnaCode, V.Chr, A.Start, A.End, A.Alt, A.Ref, V.zygosity, A.gene FROM annotazioni as A JOIN variante as V ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE A.AAchange='$aa'";
$result_dna = mysql_query($sql, $conn) or die(mysql_error());
if(mysql_num_rows($result_dna) == 0)
{
echo "<br>La ricerca non ha prodotto alcun risultato!<br>";
echo"<b>Effettuare una nuova ricerca.</b><br><br>";
}else
{?>
<div class="row">
<div class="col-mid-8 col-mid-offset-2">
<table id="table_var" "width=100%" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>AAchange</th>
<th>dnaCode</th>
<th>Chr</th>
<th>Start</th>
<th>End</th>
<th>Alt</th>
<th>Ref</th>
<th>Zigosity</th>
<th>Gene</th>
</tr>
</thead>
<tbody>
<?PHP
while ($record_dna=mysql_fetch_array($result_dna)){
echo '
<tr>
<td>'.$record_dna['AAchange'].'</td>
<td>'.$record_dna['dnaCode'].'</td>
<td>'.$record_dna['Chr'].'</td>
<td>'.$record_dna['Start'].'</td>
<td>'.$record_dna['End'].'</td>
<td>'.$record_dna['Alt'].'</td>
<td>'.$record_dna['Ref'].'</td>
<td>'.$record_dna['zygosity'].'</td>
<td>'.$record_dna['gene'].'</td>
</tr>
';
}
};?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"> </script>
<script type="text/javascript" src="js/ddtf.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" >
$('#table_var').ddTableFilter();
</script>
</body>
</html>
php database web-applications
add a comment |
I'm creating a web app which displays datas contained in a database.
I wrote the code and the app works, at least whith basic functions.
I'm already thinking about the future and that's why I'm asking for your help.
In case I will change the name of database's columns or maybe adding some new columns I will have to modify every single page of my code, if I want them to be shown in my web app.
For this reason I'd like to ask you if it is possible to write the columns name I want to import in a text file and then call this file to define which database's columns should be displayed on the net.
I'm attaching you the code I have write now so that you can understand better the part I want to change (which is the one of the 'while loop').
<html>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div id="holder">
<h1><?php echo "<font face=verdana size=30 color=#036>CAMBIO AMINOACIDICO</font>";?></h1></div>
<br>
<div id="sidebar" style="width:90%" class="sidebar">
<A HREF="ricerca_var_AA.php" class="w2-bar-item w2-button">NUOVA RICERCA</A>
  |
<A HREF="ricerca_paziente.php" class="w2-bar-item w2-button">RICERCA PER PAZIENTE</A>
  |
<A HREF="ricerca_gene.php" class="w2-bar-item w2-button">RICERCA PER GENE</A>
  |
<A HREF="ricerca_var.php" class="w2-bar-item w2-button">RICERCA PER VARIANTE</A>
  |
<A HREF="home.php" class="w2-bar-item w2-button">HOME</A>
<P> </P>
</div>
<div class="container">
<?php
$conn= mysql_connect("loc", "db", "pss");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("variant_db", $conn);
if(isset($_POST["vai"])){
$aa=$_POST["aa"];
}
echo "Verranno visualizzate le varianti per il seguente cambio di aminoacido:'<b>$aa</b>'.";?>
<br /><br />
<?php
$sql="SELECT A.AAchange, V.dnaCode, V.Chr, A.Start, A.End, A.Alt, A.Ref, V.zygosity, A.gene FROM annotazioni as A JOIN variante as V ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE A.AAchange='$aa'";
$result_dna = mysql_query($sql, $conn) or die(mysql_error());
if(mysql_num_rows($result_dna) == 0)
{
echo "<br>La ricerca non ha prodotto alcun risultato!<br>";
echo"<b>Effettuare una nuova ricerca.</b><br><br>";
}else
{?>
<div class="row">
<div class="col-mid-8 col-mid-offset-2">
<table id="table_var" "width=100%" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>AAchange</th>
<th>dnaCode</th>
<th>Chr</th>
<th>Start</th>
<th>End</th>
<th>Alt</th>
<th>Ref</th>
<th>Zigosity</th>
<th>Gene</th>
</tr>
</thead>
<tbody>
<?PHP
while ($record_dna=mysql_fetch_array($result_dna)){
echo '
<tr>
<td>'.$record_dna['AAchange'].'</td>
<td>'.$record_dna['dnaCode'].'</td>
<td>'.$record_dna['Chr'].'</td>
<td>'.$record_dna['Start'].'</td>
<td>'.$record_dna['End'].'</td>
<td>'.$record_dna['Alt'].'</td>
<td>'.$record_dna['Ref'].'</td>
<td>'.$record_dna['zygosity'].'</td>
<td>'.$record_dna['gene'].'</td>
</tr>
';
}
};?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"> </script>
<script type="text/javascript" src="js/ddtf.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" >
$('#table_var').ddTableFilter();
</script>
</body>
</html>
php database web-applications
I'm creating a web app which displays datas contained in a database.
I wrote the code and the app works, at least whith basic functions.
I'm already thinking about the future and that's why I'm asking for your help.
In case I will change the name of database's columns or maybe adding some new columns I will have to modify every single page of my code, if I want them to be shown in my web app.
For this reason I'd like to ask you if it is possible to write the columns name I want to import in a text file and then call this file to define which database's columns should be displayed on the net.
I'm attaching you the code I have write now so that you can understand better the part I want to change (which is the one of the 'while loop').
<html>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div id="holder">
<h1><?php echo "<font face=verdana size=30 color=#036>CAMBIO AMINOACIDICO</font>";?></h1></div>
<br>
<div id="sidebar" style="width:90%" class="sidebar">
<A HREF="ricerca_var_AA.php" class="w2-bar-item w2-button">NUOVA RICERCA</A>
  |
<A HREF="ricerca_paziente.php" class="w2-bar-item w2-button">RICERCA PER PAZIENTE</A>
  |
<A HREF="ricerca_gene.php" class="w2-bar-item w2-button">RICERCA PER GENE</A>
  |
<A HREF="ricerca_var.php" class="w2-bar-item w2-button">RICERCA PER VARIANTE</A>
  |
<A HREF="home.php" class="w2-bar-item w2-button">HOME</A>
<P> </P>
</div>
<div class="container">
<?php
$conn= mysql_connect("loc", "db", "pss");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("variant_db", $conn);
if(isset($_POST["vai"])){
$aa=$_POST["aa"];
}
echo "Verranno visualizzate le varianti per il seguente cambio di aminoacido:'<b>$aa</b>'.";?>
<br /><br />
<?php
$sql="SELECT A.AAchange, V.dnaCode, V.Chr, A.Start, A.End, A.Alt, A.Ref, V.zygosity, A.gene FROM annotazioni as A JOIN variante as V ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE A.AAchange='$aa'";
$result_dna = mysql_query($sql, $conn) or die(mysql_error());
if(mysql_num_rows($result_dna) == 0)
{
echo "<br>La ricerca non ha prodotto alcun risultato!<br>";
echo"<b>Effettuare una nuova ricerca.</b><br><br>";
}else
{?>
<div class="row">
<div class="col-mid-8 col-mid-offset-2">
<table id="table_var" "width=100%" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>AAchange</th>
<th>dnaCode</th>
<th>Chr</th>
<th>Start</th>
<th>End</th>
<th>Alt</th>
<th>Ref</th>
<th>Zigosity</th>
<th>Gene</th>
</tr>
</thead>
<tbody>
<?PHP
while ($record_dna=mysql_fetch_array($result_dna)){
echo '
<tr>
<td>'.$record_dna['AAchange'].'</td>
<td>'.$record_dna['dnaCode'].'</td>
<td>'.$record_dna['Chr'].'</td>
<td>'.$record_dna['Start'].'</td>
<td>'.$record_dna['End'].'</td>
<td>'.$record_dna['Alt'].'</td>
<td>'.$record_dna['Ref'].'</td>
<td>'.$record_dna['zygosity'].'</td>
<td>'.$record_dna['gene'].'</td>
</tr>
';
}
};?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"> </script>
<script type="text/javascript" src="js/ddtf.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" >
$('#table_var').ddTableFilter();
</script>
</body>
</html>
php database web-applications
php database web-applications
asked Nov 21 '18 at 7:42
user10395409
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Keeping table names in txt or xml doesn't really solve anything and brings too much extra code.
For Examle say you have a table Z
that has colums A, B C
. And you have a piece of code that looks like SELECT A, B, C FROM Z
. And you have some php logic after that.
FIRST EXAMPLE
You decided that you need to add column D
to your table Z
.
FIRST QUESTION
Will you need to select the data from the column D?
FIRST PROBLEM
If you need to select and process the data from column D, changing SELECT A, B, C FROM Z
to SELECT A, B, C, D FROM Z
probably won't be enough because you did not have any php logic that processed D before that, and you have to add it now. - Lots of extra code of controlling execution logic.
SECOND EXAMPLE
You decided that you don't need data column C
in your table Z
and you want do delete the whole column.
SECOCD PROBLEM
Here, changing SELECT A, B, C FROM Z
to SELECT A, B FROM Z
is 100% not enough.
You had some php code that proccesed data from C
column, but now you have no C
column, and the code must be removed. Also lots of extra code of controlling execution logic.
THIRD EXAMPLE
Your boss suddenly told you to add colunm N
and you had no prior knolwedge that this will happen.
THIRD PROBLEM
You could'n have forseen it in any way, so in no way you could make all the needed extra code earlier. You still have to do everything manually.
All the examples above a ment to show, that you even if you add the code for controlling execution logic, in general you cannot predict what changes the structure might get.
All the extra code looses it's value, because you made a change that you did not forsee, and besides re-writing original logic, you also have to re-write the whole code for extra logic now.
Combining everything above, developing the code comes with the risk of having to re-write it, if and when some major structure changes occur.
I hope it was somewhat informative.
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407322%2fways-of-importing-data-from-databases%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Keeping table names in txt or xml doesn't really solve anything and brings too much extra code.
For Examle say you have a table Z
that has colums A, B C
. And you have a piece of code that looks like SELECT A, B, C FROM Z
. And you have some php logic after that.
FIRST EXAMPLE
You decided that you need to add column D
to your table Z
.
FIRST QUESTION
Will you need to select the data from the column D?
FIRST PROBLEM
If you need to select and process the data from column D, changing SELECT A, B, C FROM Z
to SELECT A, B, C, D FROM Z
probably won't be enough because you did not have any php logic that processed D before that, and you have to add it now. - Lots of extra code of controlling execution logic.
SECOND EXAMPLE
You decided that you don't need data column C
in your table Z
and you want do delete the whole column.
SECOCD PROBLEM
Here, changing SELECT A, B, C FROM Z
to SELECT A, B FROM Z
is 100% not enough.
You had some php code that proccesed data from C
column, but now you have no C
column, and the code must be removed. Also lots of extra code of controlling execution logic.
THIRD EXAMPLE
Your boss suddenly told you to add colunm N
and you had no prior knolwedge that this will happen.
THIRD PROBLEM
You could'n have forseen it in any way, so in no way you could make all the needed extra code earlier. You still have to do everything manually.
All the examples above a ment to show, that you even if you add the code for controlling execution logic, in general you cannot predict what changes the structure might get.
All the extra code looses it's value, because you made a change that you did not forsee, and besides re-writing original logic, you also have to re-write the whole code for extra logic now.
Combining everything above, developing the code comes with the risk of having to re-write it, if and when some major structure changes occur.
I hope it was somewhat informative.
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
add a comment |
Keeping table names in txt or xml doesn't really solve anything and brings too much extra code.
For Examle say you have a table Z
that has colums A, B C
. And you have a piece of code that looks like SELECT A, B, C FROM Z
. And you have some php logic after that.
FIRST EXAMPLE
You decided that you need to add column D
to your table Z
.
FIRST QUESTION
Will you need to select the data from the column D?
FIRST PROBLEM
If you need to select and process the data from column D, changing SELECT A, B, C FROM Z
to SELECT A, B, C, D FROM Z
probably won't be enough because you did not have any php logic that processed D before that, and you have to add it now. - Lots of extra code of controlling execution logic.
SECOND EXAMPLE
You decided that you don't need data column C
in your table Z
and you want do delete the whole column.
SECOCD PROBLEM
Here, changing SELECT A, B, C FROM Z
to SELECT A, B FROM Z
is 100% not enough.
You had some php code that proccesed data from C
column, but now you have no C
column, and the code must be removed. Also lots of extra code of controlling execution logic.
THIRD EXAMPLE
Your boss suddenly told you to add colunm N
and you had no prior knolwedge that this will happen.
THIRD PROBLEM
You could'n have forseen it in any way, so in no way you could make all the needed extra code earlier. You still have to do everything manually.
All the examples above a ment to show, that you even if you add the code for controlling execution logic, in general you cannot predict what changes the structure might get.
All the extra code looses it's value, because you made a change that you did not forsee, and besides re-writing original logic, you also have to re-write the whole code for extra logic now.
Combining everything above, developing the code comes with the risk of having to re-write it, if and when some major structure changes occur.
I hope it was somewhat informative.
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
add a comment |
Keeping table names in txt or xml doesn't really solve anything and brings too much extra code.
For Examle say you have a table Z
that has colums A, B C
. And you have a piece of code that looks like SELECT A, B, C FROM Z
. And you have some php logic after that.
FIRST EXAMPLE
You decided that you need to add column D
to your table Z
.
FIRST QUESTION
Will you need to select the data from the column D?
FIRST PROBLEM
If you need to select and process the data from column D, changing SELECT A, B, C FROM Z
to SELECT A, B, C, D FROM Z
probably won't be enough because you did not have any php logic that processed D before that, and you have to add it now. - Lots of extra code of controlling execution logic.
SECOND EXAMPLE
You decided that you don't need data column C
in your table Z
and you want do delete the whole column.
SECOCD PROBLEM
Here, changing SELECT A, B, C FROM Z
to SELECT A, B FROM Z
is 100% not enough.
You had some php code that proccesed data from C
column, but now you have no C
column, and the code must be removed. Also lots of extra code of controlling execution logic.
THIRD EXAMPLE
Your boss suddenly told you to add colunm N
and you had no prior knolwedge that this will happen.
THIRD PROBLEM
You could'n have forseen it in any way, so in no way you could make all the needed extra code earlier. You still have to do everything manually.
All the examples above a ment to show, that you even if you add the code for controlling execution logic, in general you cannot predict what changes the structure might get.
All the extra code looses it's value, because you made a change that you did not forsee, and besides re-writing original logic, you also have to re-write the whole code for extra logic now.
Combining everything above, developing the code comes with the risk of having to re-write it, if and when some major structure changes occur.
I hope it was somewhat informative.
Keeping table names in txt or xml doesn't really solve anything and brings too much extra code.
For Examle say you have a table Z
that has colums A, B C
. And you have a piece of code that looks like SELECT A, B, C FROM Z
. And you have some php logic after that.
FIRST EXAMPLE
You decided that you need to add column D
to your table Z
.
FIRST QUESTION
Will you need to select the data from the column D?
FIRST PROBLEM
If you need to select and process the data from column D, changing SELECT A, B, C FROM Z
to SELECT A, B, C, D FROM Z
probably won't be enough because you did not have any php logic that processed D before that, and you have to add it now. - Lots of extra code of controlling execution logic.
SECOND EXAMPLE
You decided that you don't need data column C
in your table Z
and you want do delete the whole column.
SECOCD PROBLEM
Here, changing SELECT A, B, C FROM Z
to SELECT A, B FROM Z
is 100% not enough.
You had some php code that proccesed data from C
column, but now you have no C
column, and the code must be removed. Also lots of extra code of controlling execution logic.
THIRD EXAMPLE
Your boss suddenly told you to add colunm N
and you had no prior knolwedge that this will happen.
THIRD PROBLEM
You could'n have forseen it in any way, so in no way you could make all the needed extra code earlier. You still have to do everything manually.
All the examples above a ment to show, that you even if you add the code for controlling execution logic, in general you cannot predict what changes the structure might get.
All the extra code looses it's value, because you made a change that you did not forsee, and besides re-writing original logic, you also have to re-write the whole code for extra logic now.
Combining everything above, developing the code comes with the risk of having to re-write it, if and when some major structure changes occur.
I hope it was somewhat informative.
edited Nov 21 '18 at 11:17
answered Nov 21 '18 at 8:57
Eugene AnisiutkinEugene Anisiutkin
11710
11710
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
add a comment |
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
thank you for your explaination. And tha same even if I would use a javascript's function?
– user10395409
Nov 22 '18 at 7:28
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
@Gaia, Javascript itself has no ways of interacting directly with Databases. You could do it, but it would be very unsafe. But it doesn't really depend on the language, for almost any language my answer will probabply be true.
– Eugene Anisiutkin
Nov 22 '18 at 7:31
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
Any reason for the downvote?
– Eugene Anisiutkin
Nov 30 '18 at 13:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407322%2fways-of-importing-data-from-databases%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown