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

feat: add unbuffered mode, insert tablename remove `` #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jjasoncool
Copy link
Contributor

@jjasoncool jjasoncool commented Dec 1, 2020

  1. buffered mode is used to read/write huge data.
  2. Insert schema.table will show error exception.

@@ -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) . '`)
Copy link
Contributor Author

@jjasoncool jjasoncool Dec 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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.

Comment on lines +214 to +224
/**
* 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);
}

Copy link
Contributor Author

@jjasoncool jjasoncool Dec 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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.

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

Successfully merging this pull request may close these issues.

1 participant