Skip to content

Commit 9b53f6a

Browse files
committed
stable changes
1 parent d7e5749 commit 9b53f6a

21 files changed

+1876
-25
lines changed

composer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
{
22
"name": "hardeep-vicky/php-query-builder",
3-
"version" : "1.3",
3+
"version" : "1.0.0",
44
"description": "Query builder Tool for Php",
55
"require": {
6-
"php" : ">=5.2"
6+
"php" : ">=8.0"
7+
},
8+
"autoload": {
9+
"psr-4": {
10+
"HardeepVicky\\QueryBuilder\\": "src/"
11+
}
712
},
8-
"minimum-stability" : "dev"
9-
}
13+
"minimum-stability" : "stable",
14+
"prefer-stable": true,
15+
"require-dev": {
16+
"symfony/var-dumper": "^6.3"
17+
}
18+
}

composer.lock

Lines changed: 255 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Join.php renamed to src/Join.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace QueryBuilder;
2+
namespace HardeepVicky\QueryBuilder;
33

44
class Join
55
{

Query.php renamed to src/QuerySelect.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
2-
namespace QueryBuilder;
2+
namespace HardeepVicky\QueryBuilder;
33

44
class QuerySelect
55
{
66
private $table, $alias, $fields = array(), $orders = array(), $where = null, $joins = array();
77

8-
public function __construct($table, $alias = NULL)
8+
public function __construct(String $table, String $alias = NULL)
99
{
1010
$this->table = $table;
1111
$this->alias = $alias;
1212
}
1313

14-
public function setWhere($wh)
14+
public function setWhere(Where $wh)
1515
{
1616
$this->where = $wh;
1717
return $this;
@@ -43,7 +43,7 @@ public function getFields()
4343
return $this->fields;
4444
}
4545

46-
public function order($field, $order = "ASC")
46+
public function order(String $field, String $order = "ASC")
4747
{
4848
$this->orders[$field] = $order;
4949
return $this;

Where.php renamed to src/Where.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
2-
namespace QueryBuilder;
2+
namespace HardeepVicky\QueryBuilder;
33

44
class Where
55
{
66
private $op = null, $fields = array(), $where_list = array();
7-
public function __construct($op)
7+
public function __construct(String $op)
88
{
99
$this->op = " " . $op . " ";
1010
}
1111

12-
public static function init($op)
12+
public static function init(String $op)
1313
{
1414
return new Where($op);
1515
}
1616

17-
public function add($field, $value, $operator = "=", $value_type = "string")
17+
public function add(String $field, $value, String $operator = "=", String $value_type = "string")
1818
{
1919
if (
2020
strpos($field, "=") !== FALSE

test.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<?php
2-
require_once './Query.php';
3-
require_once './Where.php';
4-
require_once './Join.php';
2+
require_once './vendor/autoload.php';
53

6-
$qb = new \QueryBuilder\QuerySelect("legder_sales", "Legder");
4+
use HardeepVicky\QueryBuilder\QuerySelect;
5+
use HardeepVicky\QueryBuilder\Join;
6+
use Symfony\Component\VarDumper\VarDumper;
7+
8+
$qb = new QuerySelect("legder_sales", "Legder");
79

810
$qb->field("id");
9-
$qb->join(\QueryBuilder\Join::init("INNER JOIN", "legder_voucher_type_id", "legder_voucher_types", "LegderVoucherType", "id"));
11+
$qb->join(Join::init("INNER JOIN", "legder_voucher_type_id", "legder_voucher_types", "LegderVoucherType", "id"));
1012

11-
$legder_detail_join = \QueryBuilder\Join::init("LEFT JOIN", "id", "legder_sale_details", "LegderDetail", "legder_sale_id")->noField();
13+
$legder_detail_join = Join::init("LEFT JOIN", "id", "legder_sale_details", "LegderDetail", "legder_sale_id")->noField();
1214

13-
$product_join = \QueryBuilder\Join::init("LEFT JOIN", "product_id", "products", "Product", "id");
15+
$product_join = Join::init("LEFT JOIN", "product_id", "products", "Product", "id");
1416
$product_join->join(
15-
\QueryBuilder\Join::init("LEFT JOIN", "id", "product_files", "ProductFile", "product_id")->noField()
16-
->join(\QueryBuilder\Join::init("LEFT JOIN", "image_id", "images", "ProductFileImage", "id"))
17+
Join::init("LEFT JOIN", "id", "product_files", "ProductFile", "product_id")->noField()
18+
->join(Join::init("LEFT JOIN", "image_id", "images", "ProductFileImage", "id"))
1719
);
1820

19-
$product_join->join(\QueryBuilder\Join::init("LEFT JOIN", "category_id", "categories", "Category", "id")->field("name"));
21+
$product_join->join(Join::init("LEFT JOIN", "category_id", "categories", "Category", "id")->field("name"));
2022

2123
$legder_detail_join->join($product_join);
22-
$legder_detail_join->join(\QueryBuilder\Join::init("LEFT JOIN", "item_id", "items", "Item", "id"));
24+
$legder_detail_join->join(Join::init("LEFT JOIN", "item_id", "items", "Item", "id"));
2325

2426
$qb->join($legder_detail_join);
2527

26-
echo $qb->get();
28+
VarDumper::dump($qb->get());

0 commit comments

Comments
 (0)