Jump to content

KillGorack

Members
  • Content Count

    57
  • Joined

  • Last visited

Everything posted by KillGorack

  1. Page load I think calls the stuff like drawing canvas and the like, the problem here is that I don't know how to call the canvas to load after an ajax call. I can create the data I need, and see exactly what is expected, it's just the canvas isn't loading. <edit>The canvas div is visible, it's just not drawing what is within.</edit> Form <form METHOD="POST" ACTION=""> Project <select name="fm_project" onchange="showdata(this.form)" id="fm_project"> <option value="2">Project A</option> <option value="1">Project B</option> <option value="3">Project C</option> <option value="0" SELECTED>Select One</option></select> Module <select name="fm_module" onchange="showdata(this.form)" id="fm_module"> <option value="194">B</option> <option value="195">C</option> <option value="197">D</option> <option value="196">E</option> <option value="0" SELECTED>Select One</option></select> Stage <select name="fm_stage" onchange="showdata(this.form)" id="fm_stage"> <option value="201">stagea</option> <option value="202">stageb</option> <option value="203">stage3</option> <option value="0" SELECTED>Select One</option></select> Part <select name="fm_part" onchange="showdata(this.form)" id="fm_part"> <option value="1">Part1</option> <option value="2">Part2</option> <option value="3">part3</option> <option value="0" SELECTED>Select One</option></select> </form> <div id="graph_field">Start by choosing some filters above..</div> JS <script> function showdata(form){ var xhttp, project = form.fm_project.value, module = form.fm_module.value, stage = form.fm_stage.value, partno = form.fm_part.value; if (project == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (module == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (stage == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (partno == "") { document.getElementById("graph_field").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("graph_field").innerHTML = this.responseText; } }; xhttp.open("GET", "printme.php?app=projects&ala=csajax&fm_project="+project+"&fm_module="+module+"&fm_stage="+stage+"&fm_part='"+partno+"'", true); xhttp.send(); } </script> canvas in the Ajax call refereed in the xhttp.open line above. <canvas id="myCanvas" width="970" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); do stuff... </script> Thanks!
  2. New to Ajax, and BAD with the scripting below, bare with me. Looking to select a drop down and push all values to the query string at the end. Works perfectly with ONE select element. I just have no idea how to separate the variables. The code below is putting whatever form element I change into the first "str" variable. if possible if one of the elements below is changed, all three of variables the data is placed in the query string in the correct place if that makes sense. Form <form> <table style="width:100%"> <tr> <td style="width:85px;"> Project </td> <td style="text-align:right;"> <select name="fm_project" class="allform_select" onchange="showdata(this.value)"> <option value="2" >ProjectA</option> <option value="1" >ProjectB</option> <option value="3" >ProjectC</option> <option value="0" SELECTED>Select One</option> </select> </td> </tr> <tr> <td style="width:85px;"> Module </td> <td style="text-align:right;"> <select name="fm_module" class="allform_select" onchange="showdata(this.value)"> <option value="194" >B</option> <option value="195" >C</option> <option value="197" >D</option> <option value="196" >E</option> <option value="0" SELECTED>Select One</option></td> </select> </tr> <tr> <td style="width:85px;"> Stage </td> <td style="text-align:right;"> <select name="fm_stage" class="allform_select" onchange="showdata(this.value)"> <option value="201" >BLUE</option> <option value="202" >GREEN</option> <option value="203" >RED</option> <option value="0" SELECTED>Select One</option> </select> </td> </tr> </table> </form> Script <script> function showdata(str, stra, strb) { var xhttp; if (str == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (stra == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (strb == "") { document.getElementById("graph_field").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("graph_field").innerHTML = this.responseText; } }; xhttp.open("GET", "printme.php?app=projects&ala=csajax&fm_project="+str+"&fm_module="+stra+"&fm_stage="+strb, true); xhttp.send(); } </script>
  3. Yea I know , it's sooo much easier and going back to mysqli is a headache....currently working with some older code.. until I get everything switched over, it's not an option. investigating using "call_user_func_array" currently..
  4. Is there a way to bind parameters in a select SEPARATELY? I know how to do this in one line, but would like some direction on how to do this one line at a time, OR means to stick that array into the bind_param line where it will work with different array lengths. using mysqli to modify some older code. Understanding of course that the ?'s count must match the amount of parameters. End result to make a generic reader function. $sql = "SELECT ID, foo, bar FROM table WHERE ID = ? AND bar = ?"; $vars[] = array('typ' => "i", 'vlu' => $id); $vars[] = array('typ' => "s", 'vlu' => $rkey); $stmt = $db->prepare($sql); foreach($vars as $var){ $stmt->bind_param($var['typ'], $var['vlu']); } $stmt->execute(); $res = $stmt->get_result(); $rows = $res->fetch_array(MYSQLI_ASSOC);
  5. Just FYI, here's the first version of that loop. Creates the joins for seven separate tables, they all work. Whoot! Please ignore the darn typo. <?php // ================================================================================= // Build the sql // ================================================================================= $a = range('a', 'z'); $jn = ""; $ac = 0; foreach($fldarray as $fld){ if($fld['enabeled'] == 1 and $fld['index'] = 1){ $nm[] = $fld['human']; if($fld['opt'] == 1){ if($fld['opt_table'] <> "" and $fld['opt_field'] <> ""){ $jn .= " LEFT JOIN ".$fld['opt_table']." "."Tbl".$a[$ac]." ON "."Tbl".$a[$ac].".ID = ".$ap.".".$fld['fieldname']; $fd[] = "Tbl".$a[$ac].".".$fld['opt_field']." as Opt_".$a[$ac]; }else{ $jn .= " LEFT JOIN opt "."Tbl".$a[$ac]." ON "."Tbl".$a[$ac].".ID = ".$ap.".".$fld['fieldname']; $fd[] = "Tbl".$a[$ac].".opt_value as Opt_".$a[$ac]; } $ac = $ac + 1; }else{ $fd[] = $ap.".".$fld['fieldname']; } } } $sql = "SELECT ".implode(", ", $fd)." FROM ".$ap.$jn; // ================================================================================= // Column Headers // ================================================================================= echo "<table class=\"cells\">"; echo "<tr>"; echo "<td class=\"topper\">".implode("</td><td class=\"topper\">", $nm)."</td>"; echo "</tr>"; // ================================================================================= // The data // ================================================================================= $stmt = $db->query($sql); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($data as $datum){ echo "<tr><td class=\"topper\">".implode("</td><td class=\"topper\">", $datum)."</td></tr>"; } // ================================================================================= // Cap it off // ================================================================================= echo "</table>"; // ================================================================================= ?> Still needs some tweaks, and what-nots. but it's working.
  6. Yea I think so, I know what the join is supposed to look like, now I get to try and get that into something that can handle a few different tables. All in all my issue wasn't with how to cram text together, it was needing to have a workable example to start with. With that example I'll be good.
  7. Thanks! I'll work that into the loop. I'll push forward on the joins, I'm fairly new to them. yea lol it's even in the table spelled that way. Thanks for pointing that out. This is an instance of a typo that is replicated via copy and paste..
  8. Well I have no errors, but now when i use the PDO::FETCH_ASSOC it doesn't fetch the values I'm getting with the joins. The code; <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $sql = "SELECT app.app_name, app.app_var, Tbla.opt_value, Tblb.opt_value, app.app_enabeled, app.app_admin FROM app LEFT JOIN opt Tbla ON Tbla.ID = app.app_landing LEFT JOIN opt Tblb ON Tblb.ID = app.app_type"; $stmt = $db->query($sql); $data = $stmt->fetchall(PDO::FETCH_BOTH); echo "<pre>"; print_r($data); echo "</pre>"; ?> Results; PDO::FETCH_ASSOC Array ( [0] => Array ( [app_name] => Applications [app_var] => app [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [1] => Array ( [app_name] => Users [app_var] => usr [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [2] => Array ( [app_name] => Permissions [app_var] => acs [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [3] => Array ( [app_name] => Benchmark [app_var] => benchmark [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [4] => Array ( [app_name] => News [app_var] => nws [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [5] => Array ( [app_name] => Test Bench [app_var] => test [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [6] => Array ( [app_name] => Fields [app_var] => fld [opt_value] => DB Table [app_enabeled] => 0 [app_admin] => 1 ) [7] => Array ( [app_name] => Settings [app_var] => stg [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) ) PDO::FETCH_BOTH Array ( [0] => Array ( [app_name] => Applications [0] => Applications [app_var] => app [1] => app [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [1] => Array ( [app_name] => Users [0] => Users [app_var] => usr [1] => usr [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [2] => Array ( [app_name] => Permissions [0] => Permissions [app_var] => acs [1] => acs [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [3] => Array ( [app_name] => Benchmark [0] => Benchmark [app_var] => benchmark [1] => benchmark [opt_value] => DB Table [2] => DB Table [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [4] => Array ( [app_name] => News [0] => News [app_var] => nws [1] => nws [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [5] => Array ( [app_name] => Test Bench [0] => Test Bench [app_var] => test [1] => test [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [6] => Array ( [app_name] => Fields [0] => Fields [app_var] => fld [1] => fld [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 0 [4] => 0 [app_admin] => 1 [5] => 1 ) [7] => Array ( [app_name] => Settings [0] => Settings [app_var] => stg [1] => stg [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) )
  9. Trying to implement, stay tuned.. of this above I have no doubt.
  10. Apologies sir, your frustration is understandable. Getting data INTO the table is not an issue, it's just grabbing the key from the table, and outputting vale from the opt table. Data in the opt table below. app table "app_type", and "app_landing" are foreign keys from the opt table All I'm looking for; is to have an sql join, that will show the value in the opt table above instead of its foreign key. Works perfectly when I have only ONE field like this, but two it gives error in post above
  11. Yes absolutely, the database is NOT perfectly normalized. I have a half dozen forms, and with the multiple selection form fields that are populated with this ONE table. Because of this, is that functionality not possible? FYI SELECT app.app_name, app.app_var, opt.opt_value, opt.opt_value, app.app_enabeled, app.app_admin FROM app LEFT JOIN opt Tbla ON Tbla.ID = app.app_landing LEFT JOIN opt Tblb ON Tblb.ID = app.app_type Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'opt.opt_value' in 'field list' in C:\xampp\htdocs\portal-x\all\cn\list.php:56 Stack trace: #0 C:\xampp\htdocs\portal-x\all\cn\list.php(56): PDO->query('SELECT app.app_...') #1 C:\xampp\htdocs\portal-x\all\switch.php(82): include('C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\portal-x\index.php(17): include('C:\\xampp\\htdocs...') #3 {main} thrown in C:\xampp\htdocs\portal-x\all\cn\list.php on line 56
  12. Thanks that makes sense works great.. appreciate it! Next and last question still in the subject of joins; I have a table with some stuff that I populate selection fields with. When I have a table that uses more than ONE feature that uses this table it errors out. I'm thinking aliases, but cant get it to work. before fiddeling with the sql. SELECT app.app_name, app.app_var, opt.opt_value, app.app_enabeled, app.app_admin FROM app LEFT JOIN opt ON opt.ID = app.app_landing LEFT JOIN opt ON opt.ID = app.app_type something like? SELECT app.app_name, app.app_var, opt.opt_value, opt.opt_value, app.app_enabeled, app.app_admin FROM app LEFT JOIN opt Tbla ON Tbla.ID = app.app_landing LEFT JOIN opt Tblb ON Tblb.ID = app.app_type Still errors out
  13. Yes, the goal is to get all the records out in a table view. Structure for this example lends itself to requiring the user and app fields to have matching records. <edit> neglected to include the corrected statement; SELECT usr.usr_login, app.app_name, acs.acs_read, acs.acs_add, acs.acs_edit, acs.acs_delete, acs.acs_admin FROM acs LEFT JOIN usr ON usr.ID = acs.acs_usr LEFT JOIN app ON app.ID = acs.acs_app </edit> OK now the array from the table looks like it has the correct amount of records.. however the array looks funny to me. It looks like.. Array ( [0] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [1] => Array ( [usr_login] => fred [0] => fred [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) ) When I would like it to look like; Array ( [0] => Array ( [usr_login] => Joe [app_name] => Applications [acs_read] => 1 [acs_add] => 1 [acs_edit] => 1 [acs_delete] => 1 [acs_admin] => 1 ) [1] => Array ( [usr_login] => fred [app_name] => Users [acs_read] => 1 [acs_add] => 0 [acs_edit] => 1 [acs_delete] => 1 [acs_admin] => 0 ) ) Is this something that the SQL is doing?
  14. Never mind... trying to join a table to itself.. Sorry for the clutter..
  15. Hi, Here is my SQL, its build with a loop, and looks correct to what I think it should be. I believe the output "$data" below should only be 4 records.. though its a lot more, and some data is duplicated and shown twice in the array. Lot of stuff removed for simplicity. SELECT usr.usr_login, app.app_name, acs.acs_read, acs.acs_add, acs.acs_edit, acs.acs_delete, acs.acs_admin FROM acs LEFT JOIN usr ON usr.ID = usr.ID LEFT JOIN app ON app.ID = app.ID if it matters here's the code that generated the statement above from an array. <?php // ===================================================================================================== // preperation // ===================================================================================================== foreach($fldarray as $fld){ // get readable names and stick em into an array $nm[] = $fld['human']; // Field name, and joins (if the join is using the option table) if($fld['opt'] == 1 and ($fld['opt_table'] == "" or $fld['opt_field'] == "")){ $jn[] = array('table' => "opt", 'field' => "opt_value"); $fd[] = "opt.opt_value"; // Field name, and joins (if the join is using a table other than options) }elseif($fld['opt'] == 1 and ($fld['opt_table'] <> "" and $fld['opt_field'] <> "")){ $jn[] = array('table' => $fld['opt_table'], 'field' => $fld['opt_field']); $fd[] = $fld['opt_table'].".".$fld['opt_field']; // a field directly written no foreign keys.. }else{ $fd[] = $ap.".".$fld['fieldname']; } $sa[] = array('human' => $fld['human'], 'field' => $fld['fieldname'], 'opt_table' => $fld['opt_table'], 'opt_field' => $fld['opt_field']); } // ===================================================================================================== // Start building the SQL // ===================================================================================================== $sql = "SELECT ".implode(", ", $fd)." FROM ".$ap; // ===================================================================================================== // Add the joins if any.. // ===================================================================================================== if (isset($jn)){ foreach($jn as $j){ $sql .= " LEFT JOIN ".$j['table']." ON ".$j['table'].".ID = ".$j['table'].".ID"; } } // ===================================================================================================== $stmt = $db->query($sql); $data = $stmt->fetchAll(); echo $sql; echo "<pre>"; print_r($data); echo "</pre>"; // ===================================================================================================== ?> Tables acs ID | acs_usr | acs_app | acs_read | acs_add | acs_edit | acs_delete | acs_admin ======================================================================================== 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 app ID | app_name ============= 1 | Applications 2 | Users usr ID | login ============= 1 | joe 2 | fred 3 | carlie 4 | lisa outputs this array.. Array ( [0] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [1] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [2] => Array ( [usr_login] => fred [0] => fred [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [3] => Array ( [usr_login] => fred [0] => fred [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [4] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [5] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [6] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [7] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [8] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [9] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [10] => Array ( [usr_login] => fred [0] => fred [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [11] => Array ( [usr_login] => fred [0] => fred [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [12] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [13] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [14] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [15] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [16] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [17] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [18] => Array ( [usr_login] => fred [0] => fred [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [19] => Array ( [usr_login] => fred [0] => fred [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [20] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [21] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [22] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [23] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [24] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [25] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [26] => Array ( [usr_login] => fred [0] => fred [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [27] => Array ( [usr_login] => fred [0] => fred [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [28] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [29] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [30] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [31] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [32] => Array ( [usr_login] => Joe [0] => Joe [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [33] => Array ( [usr_login] => Joe [0] => Joe [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [34] => Array ( [usr_login] => fred [0] => fred [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [35] => Array ( [usr_login] => fred [0] => fred [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [36] => Array ( [usr_login] => carlie [0] => carlie [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [37] => Array ( [usr_login] => carlie [0] => carlie [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [38] => Array ( [usr_login] => lisa [0] => lisa [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [39] => Array ( [usr_login] => lisa [0] => lisa [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [40] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [41] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [42] => Array ( [usr_login] => fred [0] => fred [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [43] => Array ( [usr_login] => fred [0] => fred [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [44] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [45] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [46] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [47] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [48] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [49] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [50] => Array ( [usr_login] => fred [0] => fred [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [51] => Array ( [usr_login] => fred [0] => fred [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [52] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [53] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [54] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [55] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [56] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [57] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [58] => Array ( [usr_login] => fred [0] => fred [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [59] => Array ( [usr_login] => fred [0] => fred [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [60] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [61] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [62] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [63] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) )
  16. PDO update loop not perfect yet. But thought i'd plop it in here. $updts = array(); $bva = array(); foreach($fldarray as $fld){ $upfld[] = $fld['fieldname']." = :".$fld['fieldname']; $bva[] = array(":".$fld['fieldname'], check_input($_POST[$fld['fieldname']]), $fld['PDODT']); } $sql = "UPDATE ".$ap." SET ".implode(", ", $upfld)." WHERE ID = :ID"; $stmt = $db->prepare($sql); foreach($bva as $b){ $stmt->bindParam($b[0], $b[1], $b[2]); } $stmt->bindParam(":ID", $id, PDO::PARAM_INT); $stmt->execute();
  17. Thanks, just deleting and replacing reduced the time a lot. It didnt even occur to me.. I get to keep the stacks, and it's quick. I realise there were better options in your list. Tried below first and was satisfied. All I had to do was was to bring that stack into the array.. easy peasy. Thanks. // ============================================================================= // array.. // 0 name // 1 actual // 2 nominal // 3 ltl // 4 utl // 5 stack // ============================================================================= $stmt = $db->prepare("DELETE FROM dev_check WHERE dev_partno = ?"); $stmt->bind_param('s', $pn); $stmt->execute(); $mdify = 0; $stmt = $db->prepare("INSERT INTO dev_check (dev_partno, dev_feature, dev_utol, dev_ltol, dev_pushpop) VALUES (?,?,?,?,?)"); foreach($blobarray as $ft){ $stmt->bind_param("ssdds", $pn, $ft[0], $ft[4], $ft[3], $ft[5]); $stmt->execute(); $mdify = $mdify + 1; } // =============================================================================
  18. Tried that in one of the earlier versions, but the table we’re sticking data in blew up rapidly. With this configuration we get about 83K records, and the record count hangs out there. So, if we add the records as I did in the past, and you mention in this post. And past 30 samples for each unique dev_partno/dev_feature combination we start deleting the older values. A table with approx. 2.5 million records is what we’d end up with. (I know this isn’t horrible) The thought was, it might be slow at the beginning of this process (step #2 below) where we do a comparison to what is in that array to the datasets in the table so we would have to do a SELECT for each item in the array. Currently we’re grabbing one record; a rewrite would grab 30 records, in the midst of 2.5 million, 3000 times in the worst case. The process now; We parse a text file, and generate an array from it (a pretty quick 0.5sec) for the larger files. That array is then compared to data in the table with a SELECT in a loop and a very simple analysis is done. This analysis brings a subset of data from that array to the user so he/she can view it. (larger files about 15 seconds, which is manageable) This step HAS to be quick, as this is not external to their process. The data viewed also includes a hidden form with values for ALL the features (that array) On evoking the form submit button the aforementioned loop is ran to update values for all features. (takes 120 sec worst case) Full disclosure, we have not tried your suggestion past a couple 100K records. We just assumed it would be to slow at the analysis step (#2) What we’ll try I try it this way on a separate table/database and pound the schnockers out of it till we reach that size and do some comparisons, though I’m not too optimistic.
  19. Was wondering if there is a way to speed the loop below up. input array format, it can be as large as 3K items. [410] => Array ( [0] => FLTVY3226Y [1] => 47.19 [2] => 46.583 [3] => 45.583 [4] => 47.583 ) [411] => Array ( [0] => FLTVY3227X [1] => 65.927 [2] => 65.110 [3] => 64.11 [4] => 66.11 ) [412] => Array ( [0] => FLTVY3228X [1] => 63.553 [2] => 63.233 [3] => 62.233 [4] => 64.233 ) the loathsome loop // ============================================================================= // array.. // 0 name // 1 actual // 2 nominal // 3 ltl // 4 utl // ============================================================================= $adify = 0; $mdify = 0; foreach($blobarray as $ft){ $sql = "SELECT ID, dev_pushpop FROM dev_check WHERE dev_partno = '".$pn."' and dev_feature = '".$ft[0]."' LIMIT 1"; $result = $db->query($sql); $fcnt = mysqli_num_rows($result); if($fcnt < 1){ $sql = "INSERT INTO `dev_check`(`dev_partno`, `dev_feature`, `dev_ltol`, `dev_utol`, `dev_pushpop`) VALUES ('".$pn."','".$ft[0]."', ".$ft[3].", ".$ft[4].", '".$ft[1]."')"; $insert_row = $db->query($sql); $adify = $adify + 1; }else{ $row = $result->fetch_assoc(); $pushpop = explode(";", $row['dev_pushpop']); $pushpop[] = $ft[1]; $dsb = array_slice($pushpop, ($deviation_stack_size * -1)); $sqlb = "UPDATE dev_check SET dev_pushpop = '".implode(";", $dsb)."' WHERE dev_partno = '".$pn."' and dev_feature = '".$ft[0]."'"; $modify_row = $db->query($sqlb); $mdify = $mdify + 1; } } // ============================================================================= The data being updated is in a delimited format similar to, basically just adding a value at the end. and deleting one from the beginning. 0.638; 0.656; 0.771; 0.563; 0.748; 0.953; 0.980; 1.108; 0.826; 1.058; 0.986; 1.147; 1.075; 1.047; 0.759; 0.840; 0.909; 1.037; 0.893; 1.146; 1.018; 0.972; 0.911; 0.919; 0.834; 1.055; 0.847; 0.748; 0.914; 0.724 previous versions did use prepared statements. This iteration is slightly faster. Open to changing anything to speed it up as long as the data being recorded is similar.
  20. I was trying to put quotes around, its working fine now. Thank ya much! Sorry for the breach of protocol with the older thread, it wont happen again. As for the specific reason, Just trying to create forms, for adding / modifying records using data from an array created partly by reading the meta data from the table itself. I have a few tables to take care of and only want one set of code that can handle em all.
  21. [[ split from Creating a prepared statement from an array --requinix ]] I used the PDO example on the first code mac_gyver provided. That works great, and it seems I can just about understand it. One more question if it's OK to revive this thread.. I tried to stick "PDO::PARAM_STR" into a variable and call it out in a variable like below. Strings "STR" boolean "BOOL" Integers "INT" and so on.. If I place just PDO::PARAM_STR with no quotes it all works fine for it seems all data types. If I cram that parameter into a variable (within an array) and call it like below it errors. foreach($fldarray as $fld){ if($fld[9] == 1){ $insertarray[] = array('name'=>$fld[2], 'type'=>$fld[30], 'value'=>$fld[25]); } } Simple question is it OK to use PDO::PARAM_STR for everything?
  22. swoopin in to save the day again I see. Thanks.. will incorporate that for sure..
  23. There are two, to which are you referring too? Am I pushing things, or is this a bad idea?
  24. Probably pushing things. I have an edit version that works. But I'm not sure if it's a great idea to prepare and execute for each field that needs updated in the table. foreach($fieldarray as $field){ $stmt = $db->prepare("UPDATE ".$ap." SET ".$field[2]." = ? WHERE ID = ".$id); $stmt->bind_param($field[26], trim($field[25])); $stmt->execute(); } As i said, it works, but would probably be quicker in the long run to prepare all fields in the table that needed it, and then execute. whaddia think?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.