Some function are not working after tested
Francois284Modz opened this issue · 3 comments
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
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;
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.
No problème mate i will try To fix it also