Jump to content

Barand

Moderators
  • Posts

    24,604
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. Neither of those conditions I mentioned are "errors" that would generate an error message. However, how you deal with them could be different.
  2. If you get back an empty value for the price, how will you know whether it's because the record didn't exist or because there was no price in the record? Most times, when you need a query like that, the value ('small' in this case) will be from the user via GET or POST. Then you need a prepared query, which is going to upset your applecart.
  3. Try $start_from = ($page - 1) * $num_per_page;
  4. Have you tried using Microsoft's sqlsrv library? (i have feeling that replaced the mssql library) Or PDO with SQLserver driver?
  5. No, it isn't. You'll find that the final " is missing after the "sales-channel" $result .= '"'.$order->sales_channel. "\n"; should be $result .= '"'.$order->sales_channel. "\"\n"; That aside, I can't see multiple writes in the function. My guesses at the moment It is being called multiple times, each call writing a single record. It is being call recursively (What does wp_remote_post( admin_url('admin-ajax.php?action=get_batch_orders_from_api') do inside the function?
  6. Your $result string contains only one comma (after the SKU). Where do the others come from in your listed output? Are you sure that's the code causing the problem?
  7. Your three player_offers results effectively contain +----------------+-------------------+----------------+----------------+--------------+ | player_id | offers | time | commit | decommit | +----------------+-------------------+----------------+----------------+--------------+ | 808 | | | | College B | | 808 | | | College B | | | 808 | College A | 2021-04-15 | | | +----------------+-------------------+----------------+----------------+--------------+ Because the grouping only gives you one row per player, only results from one of them will be chosen by the query to appear. You see the offer data because that is aggregated (GROUP_CONCAT) to one value for the player, but you will process either the commit or decommit (if they are not aggregated.). All you are doing by removing the commit CASE is choosing not to show the data from the row it's chosen to use.
  8. Removing the commit column doesn't change the fact that you have three records for the one player in players_offers. As I said, you'll only get values from one of them as other columns are aggregated. ... exactly. Try making them GROUP_CONCAT (or some other aggregation,eg MAX) like the others
  9. I told you that same thing about nl2br() in a previous post of yours. I guess some seeds fall on stony ground.
  10. That is either by good luck or poor checking. If a player has only a single "commit/decommit" record in players_offers, it will work fine. Once you get multiple records you will only see the results from one of them because of the grouping. If you get a result for "commit" you won't see the one for "decommit", and vice versa.
  11. You are using an aggregation function (GRUP_CONCAT) in a query without a GROUP BY clause. The query, therefore, will only return a single row. The values in that row that are not aggregated will be arbitrary.
  12. All you told us is that the cUrl returns $response. The answer is proportional to the detail in the question. Your "example without authentication" seems to provide your own answer.
  13. Example... <?php //The URL of the resource that is protected by Basic HTTP Authentication. $url = 'https://gw.bilinfo.net/listingapi/api/export'; //Your username. $username = 'demo'; //Your password. $password = 'ocfB6XzF73'; //Initiate cURL. $ch = curl_init($url); //Specify the username and password using the CURLOPT_USERPWD option. curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); //Tell cURL to return the output as a string instead //of dumping it to the browser. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Execute the cURL request. $response = curl_exec($ch); //Check for errors. if(curl_errno($ch)){ //If an error occured, throw an Exception. throw new Exception(curl_error($ch)); } ?> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sample</title> </head> <body> <?= $response; ?> </body> </html>
  14. I'd just use a loop foreach ($arr['data'] as &$a) { $a['location'] = ucwords(strtolower($a['location'])); } array_map ain't going to play nice with nested arrays.
  15. vertices values are 3,5,2,4,1 Is there rule for what values are applied to the vertices? I haven't spotted the pattern yet.
  16. OK, that answers that question. Next, you say you want a function that ... The example you gave has only one sum (31). To find a maximum you need more than one. To get more than one value, something is going to have to vary in value (presumably between fixed limits). So is there something else that you aren't telling us? PS Just seen your latest post. Is that 0.5pt text in your image supposed to be legible?
  17. Fine, but why is the 4th edge (2, 4) and not (3, 4) when the pattern appears to be
  18. Your example: A=[2, 2, 1, 3] : : : : B=[1 ,3 ,4, 4] the graph has 4 edges: (2,1),(2,3),(1,4),(2,4) Why is the fourth edge (2,4) and not (3,4) ?
  19. input +----+---------------+----------+-------+---------------------+ | id | license_plate | car_bike | price | create_date | +----+---------------+----------+-------+---------------------+ | 1 | BA12ECD | 1 | 5.50 | 2021-08-21 08:09:51 | | 3 | DA12ECD | 1 | 8.50 | 2021-08-21 08:09:51 | | 6 | GA12ECD | 1 | 5.50 | 2021-08-21 08:09:51 | | 7 | HA12ECD | 1 | 8.50 | 2021-08-21 08:09:51 | | 2 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 4 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 5 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 8 | BB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 10 | DB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 13 | GB12ECD | 1 | 9.50 | 2021-08-22 08:09:51 | | 14 | HB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 9 | | 2 | 1.50 | 2021-08-22 08:09:51 | +----+---------------+----------+-------+---------------------+ query SELECT date(create_date) as parking_date , car_bike , count(*) as num , sum(price) as tot FROM tb_parking_group GROUP BY parking_date, car_bike WITH ROLLUP; output +--------------+----------+-----+-------+ | parking_date | car_bike | num | tot | +--------------+----------+-----+-------+ | 2021-08-21 | 1 | 4 | 28.00 | | 2021-08-21 | 2 | 3 | 4.50 | | 2021-08-21 | NULL | 7 | 32.50 | <-- day subtotal | 2021-08-22 | 1 | 4 | 26.00 | | 2021-08-22 | 2 | 1 | 1.50 | | 2021-08-22 | NULL | 5 | 27.50 | <-- day subtotal | NULL | NULL | 12 | 60.00 | <-- total +--------------+----------+-----+-------+
  20. If you do want to replace null values with, say, '' (an empty string), then you could do this (usng my above array)... $myarr = array_map('denullify', $myarr); function denullify($v) { return $v ?? ''; }
×
×
  • 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.