Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some function are not working after tested #1

Open
Francois284Modz opened this issue Nov 21, 2018 · 3 comments
Open

Some function are not working after tested #1

Francois284Modz opened this issue Nov 21, 2018 · 3 comments

Comments

@Francois284Modz
Copy link

hi mate your class work fine but after i tested theoptimise and the truncate function it actualy give me a erreur .

suggestion 👍
this is a lil suggestion to improve
-> add option like fetch count etc...
-> add a french documentation if you want i can make the documentation

@Francois284Modz
Copy link
Author

i tested this code and it kinda work for the count after that i dont think is good practice becuse im a noobie dev but it works

` public function select_count($table)
{
$sql_str = 'SELECT ';

    if (is_array($table))
    {
        if (is_array($table[1]))
        {
            $sql_str .= implode(', ', $table[1]) . ' FROM ';
        }
        else
        {
            $sql_str .= $table[1] . ' FROM ';
        }
        $sql_str .= $this->prefix . $table[0];
    }
    else
    {
        $sql_str .= ' COUNT(*) FROM ' . $this->prefix . $table;
    }

    try
    {
        $this->query = $this->dbh->prepare($sql_str);
        $this->query->execute();
        $res =  $this->query->fetchColumn();
        return $res;
    }
    catch (\PDOException $e)
    {
        error_log($e);

        return false;
    }
}`

//usage
$member = $db->select_count('member');
echo $member;

@nikiedev
Copy link
Owner

i tested this code and it kinda work for the count after that i dont think is good practice becuse im a noobie dev but it works

` public function select_count($table)
{
$sql_str = 'SELECT ';

    if (is_array($table))
    {
        if (is_array($table[1]))
        {
            $sql_str .= implode(', ', $table[1]) . ' FROM ';
        }
        else
        {
            $sql_str .= $table[1] . ' FROM ';
        }
        $sql_str .= $this->prefix . $table[0];
    }
    else
    {
        $sql_str .= ' COUNT(*) FROM ' . $this->prefix . $table;
    }

    try
    {
        $this->query = $this->dbh->prepare($sql_str);
        $this->query->execute();
        $res =  $this->query->fetchColumn();
        return $res;
    }
    catch (\PDOException $e)
    {
        error_log($e);

        return false;
    }
}`

//usage
$member = $db->select_count('member');
echo $member;

Thank you for your comment! I also think that there must be better way to do that but i had no time to test all and think a lot about that. I will look that on holidays and unworking functions too.

@Francois284Modz
Copy link
Author

No problème mate i will try To fix it also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants