Example #1
0
 /**
  * @throws \Exception
  */
 public function dumpXML()
 {
     $xmlReader = new XMLReader();
     $db = new Database();
     $conn = $db->connect();
     $source_file = $xmlReader->getFileList('xml', 'xml');
     if (is_array($source_file)) {
         foreach ($source_file as $path) {
             $filterXML = $xmlReader->filterXML($path);
             $db->insert('gcide', $filterXML, 'w,def');
         }
     }
     if ($conn) {
         $db->disconnect();
     }
 }
Example #2
0
<?php

chdir(__DIR__);
require_once '../../vendor/autoload.php';
new Framework\Bootstrap('..');
echo "It works\n";
\Application::log()->info('test');
$tables = \Database\Database::getTables();
foreach ($tables as $table) {
    print_r($table);
    print_r($table->getColumns());
}
Example #3
0
 /**
  * @param $user
  * @param $password
  * @return bool
  */
 function hasValidCredentials($user, $password)
 {
     $hash = $this->database->fetchColumn("SELECT password_hash FROM users WHERE username = :username", array("username" => $user));
     return self::verifyPasswordHash($password, $hash);
 }
Example #4
0
 /**
  * handle post after validation if needs
  * @param $post
  * @return array|bool
  */
 public function handlePost($post)
 {
     if (count($post) < 1) {
         return false;
     }
     $database = new Database();
     $invalidFields = [];
     $fields = [];
     foreach ($this->getForm()->getFields() as $field) {
         if ($field->isStorable()) {
             $field->setValue($post[$field->getName()]);
             if ($field->getValidation() && Validation::validate($field->getValidation(), $field->getValue())->isValid() != true) {
                 $invalidFields[$field->getName()] = $field->getValue();
             }
             $fields[$field->getName()] = $field->getValue();
         }
     }
     if (count($invalidFields) > 0 && (!isset($post['delete']) || $post['delete'] != 1)) {
         return ['status' => false, 'invalidFields' => $invalidFields];
     }
     switch ($this->getMethod()) {
         case self::_edit:
             if (isset($post['delete']) && $post['delete'] == 1) {
                 $database->delete($this->getName(), ['ID' => $this->getID()]);
                 $location = $this->getName();
             } else {
                 $database->update($this->getName(), $fields, ['ID' => $this->getID()]);
                 $location = $this->getName() . '/' . $this->getMethod() . '/' . $this->getID();
             }
             break;
         case self::_new:
             $lastInsertedID = $database->insert($this->getName(), $fields, true);
             $location = $this->getName() . '/' . self::_edit . '/' . $lastInsertedID;
             break;
     }
     return ['status' => true, 'location' => $location];
 }
Example #5
0
 /**
  * @return array
  */
 private function fetch()
 {
     $database = new Database();
     return $database->select([$this->getSourceColumn(), $this->getValueColumn()], $this->getSourceTable());
 }