Skip to content

Commit

Permalink
Initialize db automatically when calling escape. Fixes #556
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Jun 19, 2017
1 parent 1682136 commit da6ba44
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions application/Controllers/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Config\Services;
use CodeIgniter\Controller;
use CodeIgniter\I18n\Time;
use CodeIgniter\Model;
use Config\Database;
use Tests\Support\Models\JobModel;
Expand Down Expand Up @@ -186,4 +187,20 @@ public function image()
ddd($images);
}

public function time()
{
$time = new Time();

echo($time);
echo '<br/>';
echo Time::now();
echo '<br/>';
echo Time::parse('First Monday of December');
echo '<br/>';

$time = new Time('Next Monday');
die($time);
}


}
5 changes: 5 additions & 0 deletions system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ protected function _escapeString(string $str): string
return $str;
}

if (is_null($this->connID))
{
$this->initialize();
}

return $this->connID->real_escape_string($str);
}

Expand Down
5 changes: 5 additions & 0 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ public function escape($str)
*/
protected function _escapeString(string $str): string
{
if (is_null($this->connID))
{
$this->initialize();
}

return pg_escape_string($this->connID, $str);
}

Expand Down

0 comments on commit da6ba44

Please sign in to comment.