-
Notifications
You must be signed in to change notification settings - Fork 113
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
feat: add unbuffered mode, insert tablename remove `` #36
base: master
Are you sure you want to change the base?
Conversation
@@ -264,7 +275,7 @@ public function insert($tableName, $params = null) | |||
{ | |||
$keys = array_keys($params); | |||
$rowCount = $this->query( | |||
'INSERT INTO `' . $tableName . '` (`' . implode('`,`', $keys) . '`) | |||
'INSERT INTO ' . $tableName . ' (`' . implode('`,`', $keys) . '`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Insert
schema.table
will show error exception.
If the program across two db.
When use$db->insert('db2.table', para);
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.db2.table' doesn't exist.
If remove `` these quotes, I don't need to add new DB(Host, DBPort, **another_db_name**, DBUser, DBPassword)
to solve this problem.
But I don't know if this is a good practice.
/** | ||
* mysql unbuffered mode, suitable for reading huge data source | ||
* @see https://www.php.net/manual/en/mysqlinfo.concepts.buffering.php | ||
* | ||
* @return void | ||
*/ | ||
public function unbuffered() | ||
{ | ||
$this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- buffered mode is used to read/write huge data.
See https://www.php.net/manual/en/mysqlinfo.concepts.buffering.php
I think there is no need to add setAttribute() method to this class.
So I add a function that can set connection to unbuffered mode.
schema.table
will show error exception.