Jump to content

All Activity

This stream auto-updates

  1. Yesterday
  2. I am a little confused with the difference between Symfony Events and Event Listners and Doctrine Events. The Doctrine events look pretty straight forward and are primary used for entity persistence, and I have outlined my understanding below: Doctrine Lifecycle Callbacks. Single entity and single Doctrine event. Method in class. Good performance. Don't have access to Symfony services (all others do) Doctrine Lifecycle Listeners. All entities and single Doctrine event. Separate class and configured in config.se
  3. You mean this? $fields = array('id','type'); $fields[] = 'etc'; //$fields now is array('id','type', 'etc')
  4. So, like, this is going into some sort of table, and you want to be able to add columns to list in that table without having to change a whole lot of code? Like I said, fix the query to return only the columns you care about. Want to add a new column? Add it to the query. Really easy. Then when drawing the table or whatever, you can use a simple foreach($row as $column => $value) and output it as you want because $row will only have the columns you care about.
  5. Actually no, this is just adding fields to my query...I already have $sql = "SELECT * FROM orders"; outside of my function if you take a look at the entire code. What I am trying to do is add additional columns to $fields = array('id','type'); .... for example: $fields = array('id','type','etc'); and then have it pass through my function wpquery_select , which its already doing, and then have it add $rows['?'] to display or however I specifiy in my loop, without having me to manually add the columns to echo in the while loop. while($row = $results->fetch_assoc()){ echo $row['id']
  6. Awesome..thanks Phill, by looking at it it makes sense ... I will give this a try.
  7. I’m currently trying to building a websocket widget, using node package manager(NPM),WAMPserver and electronjs. the package was well installed because when i start it it works. It log into the console But i dont know how i can handle it with html on wamp server . it seems electronjs is not working for wamp and websocket.
  8. You don't insert if it is an automatically populated timestamp. https://dev.mysql.com/doc/refman/5.7/en/year.html
  9. Flexsoft

    New CMS

    Hi guys I'm planning to create a CMS using by PHP and MySQL Any Suggestions Thank you
  10. Out of curiosity, what does the details-control class do?
  11. As I am writting a project manager website and I found that I can use datatable to add button infront of row to add more sub program It's work but I want to add the class details-control by a condition So Any way I can do that? var table = $("#requests_lab").DataTable({ data: JSON.parse(data), "aoColumns": [ { "orderable": false, "mData": function (data){ if (data.Project_status >= 4) { return "className
  12. var labelsdb = <?php echo json_encode($labelsdb); ?>; //array from database for dates and times var datadb = <?php echo json_encode($datadb); ?>; // array from database for number of players var datadon = <?php echo json_encode($datadon); ?>; // array from database for number of players var datadoff = <?php echo json_encode($datadoff); ?>; // array from database for number of players var ctx = document.getElementById("myChart"); // points to canvas ctx.style.backgroundColor = "#2F3136"; //canvas background color var myChart = new Chart(ctx, { type: 'lin
  13. Last week
  14. ....Also I notice there is a column value available of YEAR, would that be more appropriate as the column definition?
  15. Thanks folks. Its only purpose is to record the year of the tournament. We maintain a history of all tournaments by the year of the tournament. The consensus from both your replies is that the value of that column should not be timestamp. I like the idea that we don't insert data into that column in the insert query as it sounds like the simplest approach (delete the insert of that variable). Under this set up can you confirm what column should be defined to so we have the ability to display the year in the form? I also like the idea of setting the year in PHP an
  16. based on the error message and the displayed spacing in the posted code, there are probably some non-printing/non-ascii character(s) between the AND and the 's (incorrect quote usage around a column name) or just the s (correct quote usage around a column name), that's breaking the sql query syntax. when you copy/pasted the echoed sql query syntax to run it directly against the database server, you are only getting the printing characters, which eliminates the cause of the sql syntax error. when you alter your code to use @Barand's suggestions, i recommend that you delete and retype everything
  17. I'm currently trying to building a websocket widget, using node package manager(NPM),WAMPserver and electronjs. the package was well installed because when i start it it works. It log into the console But i dont know how i can handle with html. it seems electronjs is not working fow wamp and websocket
  18. The SQL stays the same for PDO as it was for mysqli. Only the PHP code changes. However I recommend you use explict JOIN .. ON syntax and not the implicit FROM a, b WHERE synatx. If $db is a PDO connection, then ... $q = "SELECT SUM(quantity) AS total FROM orders INNER JOIN order_details ON orders.order_id = order_details.order_id WHERE equip_ID = ? AND start_date > ? "; $stmt = $db->prepare($q); $stmt->execute( [ $item['id'] , $start_date ] ); // pass the values here, not in the query $total = $stmt->fetchCo
  19. Taking the Column Names out of the quotes doesn't work either Also I'm new to PHP, how would I format this in PDO?
  20. Column names should not be in quotes. [edit...] While I'm here, don't put variables into your query strings, use prepared statements, and switch to PDO - it's far superior to mysqli.
  21. I'm designing a rental service and am working on a query to see if an item is available in a certain date range So far my query is as follows $q = "SELECT SUM(quantity) AS total FROM orders, order_details WHERE orders.order_id = order_details.order_id"; $q .= " AND equip_ID =".$item['id']; $q .= " AND 'start_date' > '".$start_date."'"; $result = $db->query($q); $row = mysqli_fetch_assoc($result); $sum = $row['total']; Say for instance $start_date = 2021-03-03 the output of $q would be SELECT SUM(quantity) AS total FROM orders, order_details WHERE orders
  22. If it is auto-populated with just the year then that column should be int not timestamp. However, there is probably no reason for it to be populated by the form at all. Set the year in PHP and use that same value on the form and updating the database.
  23. You've come up with a solution, but the only problem I'm hearing is "I'd like to get an array with the id and type columns from my query". If you issue the proper query, which you should be doing anyway because retrieving every column from the table when you only want a couple is wasteful of both time and resources, then you'll get an array with those columns because they're the only ones in there to begin with.
  24. Personally, I prefer to have my SQL clean and self-contained but then I don't have to work with WordPress. YMMV. Here's one way: public function wpquery_select($conn,$sql,$fields){ $sql = replace($sql,'*',implode(',',$fields); <-- Assumes your query has "select * ..." $results = $conn->query($sql); . . . Regards, Phill W.
  25. The purpose of a column defined as TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP is to record the datetime a record was added to the table. If that is its purpose you shouldn't be inserting data into that column in your insert query. If its purpose is other than that, such as recording a tournament date, then it should be redefined (probably as DATETIME or DATE).
  26. Thank you but I don't think I'm being clear. Yes I of course I know that, but I would like to specify the colums in my array .... $fields = array('id','type'); then pass it via my function wpquery_select which I am doing and have it dynamically return the columns from the database in the while loop. I don't want to have it static in the while look like... $row['id].$row[type] and so on. Basically would like to have it, where if I add more column names in the $fields = array('id','type'); its automatically taken care of within the fuction.
  1. Load more activity
  • 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.