Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by benanamen

  1. 6 hours ago, TechnoDiver said:

    I wouldn't even know where to start in the direction you're speaking of. Are you referring to frameworks like Laravel?

    I am not suggesting you go to a Framework although they are structured the way I mentioned. Check out this free Laracast video series on PHP. It is the only video tutorial I have seen that I would recommend to anyone. It will get you going in the right direction. Watch each one even if you understand it already.

    The PHP Practitioner
    https://laracasts.com/series/php-for-beginners

    • Like 1
  2. The "real" problem is that you have no Architecture to your site. Having a direct correlation of URLS to file paths is a very restrictive and low level design. By designing using a "Front Controller" or "MVC" pattern with a single point of entry you could move files anywhere you want without affecting the URLS. Optimally, all your files should be above the root save for the index.php and your assets such as images, JS and CSS.

    It may be above your current skill level but it is well worth learning.

  3. After re-reading this thread it seems apparent that what you really need is a BI (Business Intelligence) tool that is purpose built for the real problem you are trying to solve, generating various reports. Tableau and Power BI are such tools. (There are many others).

    I am going to bow out of your specific request since I think you are going about it wrong and are not willing to do anything beyond "how" you are trying to solve a problem.

  4. Since you are insisting on doing things they way you are, here is working code.
     

    <?php
    
    $host = '127.0.0.1';
    $db   = 'test';
    $user = 'root';
    $pass = '';
    $charset = 'utf8mb4';
    
    $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
    $options = [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
    ];
    try {
         $pdo = new PDO($dsn, $user, $pass, $options);
    } catch (\PDOException $e) {
         throw new \PDOException($e->getMessage(), (int)$e->getCode());
    }
    
    $sql = 'DROP PROCEDURE IF EXISTS test1';
    $pdo->exec($sql);
    
    $sql ='CREATE PROCEDURE test1(IN LastID INT(5))
    BEGIN
    SELECT person.RecordID AS PersonID, organization.Name FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 10;
    SELECT person.RecordID AS PersonID, organization.Name, organization.City, organization.State, organization.Zip FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 25;
    END';
    
    $pdo->exec($sql);

     

  5. 35 minutes ago, Barand said:

    I knew when I was writing that there would be some purist raising an objection. However I decided the returns in this case weren't worth the extra effort and took a pragmatic approach.

    It's hardly purist. It is basic Database Normalization. What are you going to do if there are more image caps, keep adding columns? +2 to the ADDITIONAL bad DB design. How is the OP supposed to learn when a forum expert shows them the wrong way.

  6. It should be noted that trimming $_POST with array_map as shown will fail on multi-dimensional arrays. A simple function will solve the problem.

     

    function trim_array($input)
    {
        if (!is_array($input))
        {
            return trim($input);
        }
        return array_map('trim_array', $input);
    }
    
    $_POST = [
        ["data1 ", "     data2", "  data3  "],
        ["data4", " data5", "    data6       "]];
    
    $post = trim_array($_POST);
    var_dump($post);

     

  7. As far as file names, what DOES make a difference is underscore and dash to separate words. As simple search proves this out.

    On google search fast_cars and see returned result count, then try fast-cars. I get 13,000,000 results and 1,600,000,000 respectively

    Bottom line, use dashes as the separator.

×
×
  • 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.