Code Monkey home page Code Monkey logo

Comments (4)

TheTechsTech avatar TheTechsTech commented on June 12, 2024

Where is the full SQL query statement as example you using?

Where are you getting this execution info from?

Anyway, this library main focus is using the CRUD shortcut methods, not actually writing full SQL statements by hand. It's really not concerned about the actual underlying database. One set of statements with any vendor.

Look over the tests folder, see if any of them results in the same behavior.

from ezsql.

carlo-fontanos avatar carlo-fontanos commented on June 12, 2024

Hello, thanks for the quick reply.

Here is the full SQL query statement example with PHP:

<?php 
require 'vendor/autoload.php';

use ezsql\Database;

define( 'DB_NAME', 			'mydb' );
define( 'DB_USER', 			'root' );
define( 'DB_PASSWORD', 		'password');
define( 'DB_HOST', 			'127.0.0.1' );

$db = Database::initialize('mysqli', [DB_USER, DB_PASSWORD, DB_NAME, DB_HOST], 'db1');

$result = $db->get_var("SELECT COUNT(cid) FROM customer");

print_r($result);

And here's the result when I use SET GLOBAL general_log = 'ON'; (this is where I'm getting the exeuction info from)

2023-01-04T03:47:30.513881Z	 1669 Connect	root@localhost on mydb using TCP/IP
2023-01-04T03:47:30.514375Z	 1669 Query	SET NAMES utf8
2023-01-04T03:47:30.514583Z	 1669 Init DB	mydb
2023-01-04T03:47:30.514750Z	 1669 Query	SHOW CHARACTER SET
2023-01-04T03:47:30.516131Z	 1669 Query	SET NAMES 'utf8'
2023-01-04T03:47:30.516353Z	 1669 Query	SELECT COUNT(cid) FROM customer
2023-01-04T03:47:30.531272Z	 1669 Quit

Notice the SET NAMES utf8 and SHOW CHARACTER SET - everytime I run a SELECT I see these 2 queries. And on our production site they're the most executed query recorded.

from ezsql.

TheTechsTech avatar TheTechsTech commented on June 12, 2024

I think you will need to understand how PHP mysqli_query function or how the internals MySQL driver works.

Check lib/Database/ez_mysqli.php at query(), connect() and dbSelect() methods, and overwrite them.

from ezsql.

carlo-fontanos avatar carlo-fontanos commented on June 12, 2024

I've been trying to understand the code under lib/Database/ez_mysqli.php but I'm still not sure if it's safe to comment out / remove this code:

if ($charset != '') {
    $encoding = \strtolower(\str_replace('-', '', $charset));
    $charsetArray = array();
    $recordSet = \mysqli_query($this->dbh, 'SHOW CHARACTER SET');
    while ($row = \mysqli_fetch_array($recordSet, \MYSQLI_ASSOC)) {
        $charsetArray[] = $row['Charset'];
    }

    if (\in_array($charset, $charsetArray)) {
        \mysqli_query($this->dbh, 'SET NAMES \'' . $encoding . '\'');
    }
}

From my tests on the application, everything still seems to be functioning properly.

Please advice.

from ezsql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.