🏡 index : ~doyle/koselig.git

author Jordan Doyle <jordan@doyle.wf> 2016-10-25 16:57:00.0 +00:00:00
committer Jordan Doyle <jordan@doyle.wf> 2016-10-25 16:57:00.0 +00:00:00
commit
e8acfc1a3e223c33213263a298369bf519d17609 [patch]
tree
3aff53246321f8b5a45a6099de0d9a9f1212900e
parent
2bd278137cadda421f1c26cba356128c8668ee37
parent
f3a28ab91f565fe04c71ac43e29da2829cb78004
download
e8acfc1a3e223c33213263a298369bf519d17609.tar.gz

Merge branch 'master' of https://github.com/koselig/library



Diff

 src/Providers/WordpressServiceProvider.php |  1 +-
 src/Proxy/WordpressDatabase.php            | 71 ++++++++++++++++---------------
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/src/Providers/WordpressServiceProvider.php b/src/Providers/WordpressServiceProvider.php
index 62dc52b..93ec772 100644
--- a/src/Providers/WordpressServiceProvider.php
+++ b/src/Providers/WordpressServiceProvider.php
@@ -3,7 +3,6 @@ namespace Koselig\Providers;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Koselig\Proxy\WordpressDatabase;
use Koselig\Support\Action;
use Koselig\Support\Wordpress;

diff --git a/src/Proxy/WordpressDatabase.php b/src/Proxy/WordpressDatabase.php
index 641ab5c..14ed675 100644
--- a/src/Proxy/WordpressDatabase.php
+++ b/src/Proxy/WordpressDatabase.php
@@ -39,6 +39,7 @@ class WordpressDatabase extends wpdb
     * through this class.
     *
     * @param bool $allow_bail
     *
     * @return void
     */
    public function db_connect($allow_bail = true)
@@ -89,7 +90,7 @@ class WordpressDatabase extends wpdb
        $incompatible_modes = (array) apply_filters('incompatible_sql_modes', $this->incompatible_modes);

        foreach ($modes as $i => $mode) {
            if (in_array($mode, $incompatible_modes)) {
            if (in_array($mode, $incompatible_modes, true)) {
                unset($modes[$i]);
            }
        }
@@ -98,14 +99,14 @@ class WordpressDatabase extends wpdb
    }

    /**
     * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string()
     * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string().
     *
     * @see mysqli_real_escape_string()
     * @see mysql_real_escape_string()
     * @since 2.8.0
     * @access private
     *
     * @param  string $string to escape
     *
     * @return string escaped
     */
    public function _real_escape($string)
@@ -114,37 +115,6 @@ class WordpressDatabase extends wpdb
    }

    /**
     * Internal function to perform the mysql_query() call.
     *
     * @since 3.9.0
     *
     * @access private
     * @see wpdb::query()
     *
     * @param string $query The query to run.
     */
    private function _do_query($query)
    {
        if (defined('SAVEQUERIES') && SAVEQUERIES) {
            $this->timer_start();
        }

        if (preg_match('/^\s*(insert|create|alter|truncate|drop)\s/i', $query)) {
            $this->last_result = $this->result = DB::statement($query);
        } elseif (preg_match('/^\s*(delete|update|replace)\s/i', $query)) {
            $this->last_result = $this->result = DB::affectingStatement($query);
        } else {
            $this->last_result = $this->result = DB::select($query);
        }

        $this->num_queries++;

        if (defined('SAVEQUERIES') && SAVEQUERIES) {
            $this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
        }
    }

    /**
     * Perform a MySQL database query, using current database connection.
     *
     * More information can be found on the codex page.
@@ -152,12 +122,14 @@ class WordpressDatabase extends wpdb
     * @since 0.71
     *
     * @param string $query Database query
     *
     * @return int|false Number of rows affected/selected or false on error
     */
    public function query($query)
    {
        if (!$this->ready) {
            $this->check_current_query = true;

            return false;
        }

@@ -186,6 +158,7 @@ class WordpressDatabase extends wpdb
            $this->flush();
            if ($stripped_query !== $query) {
                $this->insert_id = 0;

                return false;
            }
        }
@@ -206,6 +179,7 @@ class WordpressDatabase extends wpdb
            }

            $this->print_error($this->last_error);

            return false;
        }

@@ -222,4 +196,33 @@ class WordpressDatabase extends wpdb

        return $return_val;
    }

    /**
     * Internal function to perform the mysql_query() call.
     *
     * @since 3.9.0
     * @see wpdb::query()
     *
     * @param string $query The query to run.
     */
    private function _do_query($query)
    {
        if (defined('SAVEQUERIES') && SAVEQUERIES) {
            $this->timer_start();
        }

        if (preg_match('/^\s*(insert|create|alter|truncate|drop)\s/i', $query)) {
            $this->last_result = $this->result = DB::statement($query);
        } elseif (preg_match('/^\s*(delete|update|replace)\s/i', $query)) {
            $this->last_result = $this->result = DB::affectingStatement($query);
        } else {
            $this->last_result = $this->result = DB::select($query);
        }

        $this->num_queries++;

        if (defined('SAVEQUERIES') && SAVEQUERIES) {
            $this->queries[] = [$query, $this->timer_stop(), $this->get_caller()];
        }
    }
}