Esempio n. 1
0
 public function testEscape()
 {
     $dr = SqlBuilder::get();
     $test = "O'Reilly % _";
     same($dr->escape($test, false), "O\\'Reilly % _");
     same($dr->escape($test, true), 'O\\\'Reilly \\% \\_');
 }
Esempio n. 2
0
 /**
  * Cms constructor.
  * @param array $values
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['type'] = $this->_getCMSType();
     $this['ns'] = __NAMESPACE__ . '\\' . $this['type'] . '\\';
     $this['db'] = function ($cms) {
         SqlBuilder::set($cms['type']);
         // init SQLBuilder Driver
         $className = $cms['ns'] . 'Database';
         $database = new $className($cms);
         return $database;
     };
     $this['path'] = function ($cms) {
         $className = $cms['ns'] . 'Path';
         /** @var AbstractPath $helper */
         $helper = new $className($cms);
         $path = Path::getInstance('crosscms');
         $path->setRoot($helper->getRoot());
         $preDefinedPaths = ['upload' => $helper->getUpload(), 'cache' => $helper->getCache(), 'tmpl' => $helper->getTmpl(), 'logs' => $helper->getLogs(), 'tmp' => $helper->getTmp(), 'crosscms' => __DIR__ . '/../src'];
         foreach ($preDefinedPaths as $alias => $pathValue) {
             if (!is_dir($pathValue)) {
                 mkdir($pathValue, 0755, true);
             }
             $path->set($alias, $pathValue);
         }
         return $path;
     };
     $this['events'] = function ($cms) {
         $eventManager = new EventManager();
         $className = $cms['ns'] . 'Events';
         $helper = new $className($cms, $eventManager);
         return $helper;
     };
     $this['lang'] = function ($cms) {
         $className = $cms['ns'] . 'Lang';
         /** @var AbstractLang $helper */
         $helper = new $className($cms);
         $lang = new Lang($helper->getCode());
         $helper->setCustomLang($lang);
         return $helper;
     };
 }
Esempio n. 3
0
<?php

/**
 * JBZoo SqlBuilder
 *
 * This file is part of the JBZoo CCK package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   SqlBuilder
 * @license   MIT
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
 * @link      https://github.com/JBZoo/SqlBuilder
 * @author    Denis Smetannikov <*****@*****.**>
 */
namespace JBZoo\PHPUnit;

// @codingStandardsIgnoreFile
// @codeCoverageIgnoreStart
use JBZoo\SqlBuilder\SqlBuilder;
// init life hack
$connection = mysqli_connect($_ENV['mysql_host'], $_ENV['mysql_user'], $_ENV['mysql_pass'], $_ENV['mysql_db'], $_ENV['mysql_port']);
SqlBuilder::set('mysqli', $connection, 't_');
// @codeCoverageIgnoreEnd
Esempio n. 4
0
 /**
  * @param string $condition
  * @param string $value
  * @return string
  *
  * @codeCoverageIgnore
  */
 public function clean($condition, $value = null)
 {
     return SqlBuilder::get()->clean($condition, $value);
 }
Esempio n. 5
0
 /**
  * @return \JBZoo\SqlBuilder\Driver\Driver|null
  */
 protected function _getDriver()
 {
     return SqlBuilder::get();
 }
Esempio n. 6
0
 /**
  * @return \JBZoo\SqlBuilder\Driver\Driver
  */
 public function getDriver()
 {
     return SqlBuilder::get();
 }