Exemple #1
0
 function testBrxCntDist()
 {
     $systems = array("NMBS", "MIVB");
     $data = new DataLayer("EN");
     //Brussel Centraal liveboard
     $liveboard = $data->getLiveboard(4.35, 50.85, "DEP", $systems[0]);
     $this->assertEqual($liveboard[0]["stationinfo"]["distance"], "455m");
 }
 public static function Insert(ContactsDetails $c)
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $lab_contacts = array('contact_name' => $c->_contact_name, 'contact_email' => $c->_contact_email, 'contact_type' => $c->_contact_type, 'contact_company' => $c->_contact_company, 'contact_title' => $c->_contact_title, 'contact_subject' => $c->_contact_subject, 'contact_message' => $c->_contact_message, 'contact_date_submited' => $c->_contact_date_submited);
     $dl->insert("lab_contacts", $lab_contacts) or die($dl->getError());
     $val_array = array("id" => $dl->inserted(""));
     return $val_array;
 }
 public function Delete()
 {
     $datalayer = new DataLayer();
     $datalayer->OpenConnection();
     try {
         $datalayer->DeleteObject($this);
     } catch (Exception $e) {
         $this->ServerErr = $e->getMessage();
         $this->ServerErrNo = $e->getCode();
     }
     $datalayer->CloseConnection();
 }
 public function test1()
 {
     DataLayer::testRow0a(1);
     DataLayer::testRows1(1);
     DataLayer::testRowsWithIndex1(100);
     DataLayer::testRowsWithKey1(100);
 }
Exemple #5
0
 public static function RightBlocks($page_id)
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT block_id,page_id,block_title,block_has_title,block_content";
     $query .= " FROM ";
     $query .= "lab_blocks";
     $conditions = array('block_direction' => "RIGHT", 'page_id' => $page_id);
     $order = array('block_order' => "ASC");
     $limit = array();
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
 public static function ChildServicesList($service_parent_id)
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT service_id,service_parent_id,service_title,service_description,service_date_submited";
     $query .= " FROM ";
     $query .= "lab_services";
     $conditions = array('service_parent_id' => $service_parent_id);
     $order = array('service_order' => "ASC", 'service_title' => "ASC", 'service_date_submited' => "DESC");
     $limit = array();
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
 public static function CategoryList()
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT category_id,category_title";
     $query .= " FROM ";
     $query .= "lab_categories";
     $conditions = array();
     $order = array('category_title' => "ASC", 'category_id' => "ASC");
     $limit = array();
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
 /**
  * Test constant __DIR__ with several characters that need escaping.
  */
 public function test5()
 {
     $dir_name = realpath(__DIR__ . '/../../test/MySql/psql/ test_escape \' " @ $ ! .');
     if ($dir_name) {
         $ret = DataLayer::magicConstant05();
         $this->assertEquals($dir_name, $ret);
     }
 }
 public static function ClientsFeatured()
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT client_id,client_title,client_brief,client_thumbnail,client_date_submited";
     $query .= " FROM ";
     $query .= "lab_clients";
     $conditions = array('client_featured' => "Y");
     $order = array('client_order' => "ASC", 'client_title' => "ASC", 'client_date_submited' => "DESC");
     $limit = "5";
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
 public static function PortfolioDetails($portfolio_id)
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT port.portfolio_id,port.category_id,cat.category_title,port.portfolio_title,port.portfolio_brief,port.portfolio_thumbnail,port.portfolio_image,port.portfolio_date_submited";
     $query .= " FROM ";
     $query .= "lab_portfolios as port";
     $query .= " INNER JOIN ";
     $query .= "lab_categories as cat";
     $query .= " ON ";
     $query .= "port.category_id = cat.category_id";
     $conditions = array('portfolio_id' => $portfolio_id);
     $order = array();
     $limit = array(1);
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
Exemple #11
0
 public static function GetSelectedPage($page_id)
 {
     global $conn;
     $dl = new DataLayer($conn->link);
     $dl->debug = false;
     $query = "SELECT page.page_id,\r\n\t\t\t\t\t\tpage.control_id, \r\n\t\t\t\t\t\tpage.page_title,\r\n\t\t\t\t\t\tpage.page_description, \r\n\t\t\t\t\t\tpage.page_meta_keyword,\r\n\t\t\t\t\t\tpage.page_meta_description,\r\n\t\t\t\t\t\tcontrol.control_file";
     $query .= " FROM ";
     $query .= "lab_pages as page";
     $query .= " LEFT OUTER JOIN ";
     $query .= "lab_controls as control";
     $query .= " ON ";
     $query .= "page.control_id = control.control_id";
     $conditions = array('page.page_id' => $page_id);
     $order = array();
     $limit = "0,1";
     $fun_array = $dl->select($query, $conditions, $order, $limit) or die($dl->getError());
     if (!empty($fun_array[0])) {
         return $fun_array;
     }
     return false;
 }
Exemple #12
0
    /**
     * Stored routine with designation type table must show table.
     */
    public function test1()
    {
        $template_table = '
+---------+---------+---------+---------+---------------------+------+------+
| tst_c00 | tst_c01 | tst_c02 | tst_c03 |       tst_c04       |  t   |  s   |
+---------+---------+---------+---------+---------------------+------+------+
| Hello   |       1 |   0.543 | 1.23450 | 2014-03-27 00:00:00 | 4444 |    1 |
| World   |       3 | 0.00003 | 0.00000 | 2014-03-28 00:00:00 |      |    1 |
+---------+---------+---------+---------+---------------------+------+------+
';
        ob_start();
        DataLayer::testTable();
        $table = ob_get_contents();
        ob_end_clean();
        $this->assertEquals($table, $template_table);
    }
Exemple #13
0
 /**
  * Function is initializing App data storage
  * @param string $storageType
  * @return FileDataConnector|MySql|null return the specific type connector
  */
 public static function Init($storageType)
 {
     self::$_logger = Logger::GetInstance();
     $logLevel = LogLevels::INFO;
     if (self::$_connector == NULL) {
         switch ($storageType) {
             default:
             case AppConstants::FILE_STORAGE:
                 self::$_connector = new FileDataConnector();
                 self::$_logger->WriteLog('File data storage inited.', $logLevel);
                 break;
             case AppConstants::MYSQL_STORAGE:
                 self::$_connector = new MySql();
                 self::$_logger->WriteLog('SQL data storage inited.', $logLevel);
                 break;
         }
     }
     return self::$_connector;
 }
 /**
  * Test must not be a problem.
  */
 public function test2()
 {
     $data[] = ['field1' => 1, 'field2' => 1, 'field3' => 1, 'field4' => 1, 'field5' => 1];
     //  int,
     DataLayer::testBulkInsert02($data);
 }
Exemple #15
0
									    <tbody>
									      <?php 
$sort = " ";
if (isset($_GET['name'])) {
    $sort = 2;
}
if (isset($_GET['topic'])) {
    $sort = 6;
}
if (isset($_GET['time'])) {
    $sort = 3;
}
if (isset($_GET['status'])) {
    $sort = 5;
}
if (isset($_GET['school'])) {
    $sort = 7;
}
$data = new DataLayer();
$res = $data->getAll($sort, $_SESSION['school'], $_SESSION['sec']);
foreach ($res as $row) {
    echo "<tr>\n                                                <td>{$row['2']}</td>\n                                                <td>{$row['3']}</td>\n                                                <td>{$row['6']}</td>\n                                                <td>{$row['7']}</td>\n                                                <td>{$row['8']}</td>\n                                                <td>{$row['5']}</td>\n                                                <td><a href='{$row['4']}'>{$row['4']}</a></td>\n                                              </tr>";
}
?>
									    </tbody>
									  </table>
				</div>
				</div>
			</div>
		</div>
	</body>
 */
require_once "Complaint.php";
require_once "DataLayer.php";
require_once "lib.php";
$complaints;
$searchText = "";
$errors = array();
//$hey = new DataLayer();
//$hey->addPicture();
if (count($_POST) > 0) {
    if ($_POST["search"]) {
        $searchText = $_POST["searcher"];
        if (empty($searchText)) {
            $errors[] = "Please type some text to search";
        } else {
            $dl = new DataLayer();
            $complaints = $dl->findComplaintByIssue($searchText);
            if (count($complaints) < 1) {
                $errors[] = "Your search yielded no results";
            }
        }
    } else {
        $complaints = null;
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
 public function Delete()
 {
     require_once dirname(__FILE__) . '/datalayer.php';
     $datalayer = new DataLayer();
     $datalayer->DeleteObject($this);
 }
 /**
  * Stored routine with designation type rows_with_index must return empty array when no rwos are selected.
  */
 public function test2()
 {
     $rows = DataLayer::testRowsWithIndex1(0);
     $this->assertInternalType('array', $rows);
     $this->assertCount(0, $rows);
 }
Exemple #19
0
 /**
  * An exception must be thrown when a stored routine with designation type row1 returns more than 1 rows.
  *
  * @expectedException SetBased\Stratum\Exception\ResultException
  */
 public function test3()
 {
     DataLayer::testRow1a(2);
 }
 /**
  * An exception must be thrown when a stored routine with designation type singleton1 returns more than 1 values.
  *
  * @expectedException SetBased\Stratum\Exception\ResultException
  */
 public function test3()
 {
     DataLayer::testSingleton1a(2);
 }
<?php

// includes
require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'template.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'datalayer.php';
// datalayer
$db = new DataLayer();
// actions
if (isset($_REQUEST['btnCancel'])) {
    header("Location: browse.php");
    exit(0);
}
if (isset($_REQUEST['btnOk'])) {
    $newContact = new Contact();
    $newContact->name = $_POST['name'];
    $newContact->email = $_POST['email'];
    $newContact->role = $_POST['role'];
    $newContact->comments = $_POST['comments'];
    $newId = $db->insertContact($newContact);
    if ($_FILES['picture']['tmp_name'] != "") {
        // upload picture
        $copyTo = __DIR__ . '/files/avatars/avatar_' . $newId . '.jpg';
        $copyFrom = $_FILES['picture']['tmp_name'];
        move_uploaded_file($copyFrom, $copyTo);
        boxScaleJpg($copyTo, 100, 70);
    } else {
        $copyTo = __DIR__ . '/files/avatars/avatar_' . $newId . '.jpg';
        $copyFrom = __DIR__ . '/files/avatars/no_thn.jpg';
        copy($copyFrom, $copyTo);
    }
    header("Location: browse.php");
<?php

/**
 * Created by PhpStorm.
 * User: randyjp
 * Date: 4/29/15
 * Time: 11:27 PM
 */
require_once "Complaint.php";
require_once "DataLayer.php";
require_once "lib.php";
$dl = new DataLayer();
$id = $_GET["id"];
$messages = array();
$success = true;
if (count($_POST) > 0) {
    $id = $_POST["hiddenId"];
    if (!empty($_POST["txtComments"])) {
        $dl->addCommentById($id, $_POST["txtComments"]);
        $messages[] = "Comment Added Successfully";
    } else {
        $messages[] = "Comments can't be empty.";
        $success = false;
    }
}
if (empty($id)) {
    header("location:index.php");
    die;
}
$complaint = $dl->findComplaintById($id);
?>
 private static function prettifydatavalue($value, $fieldinfo)
 {
     // tinyint_    1
     // boolean_    1
     // smallint_    2
     // int_        3
     // float_        4
     // double_        5
     // real_        5
     // timestamp_    7
     // bigint_        8
     // serial        8
     // mediumint_    9
     // date_        10
     // time_        11
     // datetime_    12
     // year_        13
     // bit_        16
     // decimal_    246
     // text_        252
     // tinytext_    252
     // mediumtext_    252
     // longtext_    252
     // tinyblob_    252
     // mediumblob_    252
     // blob_        252
     // longblob_    252
     // varchar_    253
     // varbinary_    253
     // char_        254
     // binary_        25
     $retval = $value;
     if ($value) {
         if (DataLayer::fieldisnotnumeric($fieldinfo)) {
             //timestamp - 7
             //datetime - 12
             if (($fieldinfo->type == 7 || $fieldinfo->type == 12) && $value == 'now()') {
                 $retval = $value;
             } else {
                 $retval = "'" . $value . "'";
             }
         }
     } else {
         $retval = 'null';
     }
     return $retval;
 }
Exemple #24
0
 public function Delete()
 {
     require_once 'common/datalayer.php';
     $datalayer = new DataLayer();
     $datalayer->DeleteObject($this);
 }
Exemple #25
0
<?php

require "dataLayer.class.php";
$data = new DataLayer();
session_start();
if (!isset($_SESSION['userId']) || !$data->checkToken($_SESSION['userId'], session_id())) {
    header("Location: login.php");
    die;
}
if ($title === "prof") {
    $res = $data->getStudent($_SESSION['userId']);
    if ($res[6] != 1) {
        header("Location: login.php");
    }
}
Exemple #26
0
 /**
  * Stored routine with designation type function execute stored function and return result.
  */
 public function test2()
 {
     $ret = DataLayer::testFunction(3, 4);
     $this->assertNotEquals(5, $ret);
 }
Exemple #27
0
 /**
  * Stored routine with designation type rows must return an array with 3 rows when 3 rows are selected.
  */
 public function test3()
 {
     $ret = DataLayer::testRows1(2);
     $this->assertInternalType('array', $ret);
     $this->assertCount(2, $ret);
 }
 /**
  * An exception must be thrown when a stored routine with designation type singleton1 returns more than 1 values.
  *
  * @expectedException SetBased\Stratum\Exception\ResultException
  */
 public function test3()
 {
     DataLayer::testSingleton1aWithLob(2, 'blob');
 }
Exemple #29
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once 'DAL/DataLayer.php';
require_once 'DAL/usersListGen.php';
require_once 'DAL/AppConstants.php';
$serializer = new UserListGenerator('userList.json');
//$serializer->WriteData();
$tmp = new DataLayer();
//echo 'DataLayer: ' . $tmp;
$connector = $tmp->GetConnector();
$user = $connector->getUser('test0', 'testpass0');
//echo ('User: '. $user. "\n");
Exemple #30
0
<?php

// includes
require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'datalayer.php';
// datalayer
$db = new DataLayer();
// to demonstrate the async aspect
sleep(1);
// get vars
$action = isset($_GET['action']) ? $_GET['action'] : '';
// all action; unused in this exercise but provided as sample action
// usage: call api.php?action=all
if ($action == 'all') {
    // get contacts
    $contacts = $db->getContacts();
    // send to client
    exit(json_encode(array('contacts' => $contacts, 'status' => 200, 'message' => 'delete OK')));
}
// delete action
if ($action == 'delete') {
    // get id
    $id = isset($_GET['id']) ? $_GET['id'] : '';
    // contact does not exist
    if (!$db->existsContact($id)) {
        // give notice to client
        http_response_code(404);
        exit(json_encode(array('status' => 404, 'message' => 'delete failed: contact not found')));
    }
    // delete it
    $db->deleteContact($id);
    // give notice to client