Compare commits
7 Commits
ece32b9bbe
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ce03bdb27d | |||
| b24598b118 | |||
| 5019b89cc0 | |||
| d030e8d30e | |||
| b2672ad92f | |||
| 4c57770b43 | |||
| 8e84450f95 |
80
readme.org
80
readme.org
@@ -33,83 +33,85 @@ En la siguiente tabla se encuentra la lista de estados de los gestores de bases
|
|||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| method | MySQL/MariaDB | sqlite3 | postgreSQL |
|
| method | MySQL/MariaDB | sqlite3 | postgreSQL |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| db | ok | ok | |
|
| db | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| query | ok | ok | |
|
| query | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| resetQuery | ok | ok | |
|
| resetQuery | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| buildQuery | ok | ok | |
|
| buildQuery | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| getInstance | ok | ok | |
|
| getInstance | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| getVars | ok | ok | |
|
| getVars | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| className | ok | ok | |
|
| className | ok | ok | pk |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| table | ok | ok | |
|
| table | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| update | ok | ok | |
|
| update | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| beginTransaction | ok | ok | |
|
| beginTransaction | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| rollBack | ok | ok | |
|
| rollBack | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| commit | ok | ok | |
|
| commit | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| add | ok | ok | |
|
| add | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| save | ok | ok | |
|
| save | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| delete | ok | ok | |
|
| delete | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| select | ok | ok | |
|
| select | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| from | ok | ok | |
|
| from | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| where | ok | ok | |
|
| where | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereIn | ok | ok | |
|
| whereIn | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereNotIn | ok | ok | |
|
| whereNotIn | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereNull | ok | ok | |
|
| whereNull | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereNotNull | ok | ok | |
|
| whereNotNull | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereExists | ok | ok | |
|
| whereExists | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| whereNotExists | ok | ok | |
|
| whereNotExists | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| leftJoin | ok | ok | |
|
| leftJoin | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| rightJoin | ok | fixed | |
|
| rightJoin | ok | fixed | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| innerJoin | ok | ok | |
|
| innerJoin | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| and | ok | ok | |
|
| crossJoin | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| or | ok | ok | |
|
| and | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| groupBy | ok | ok | |
|
| or | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| limit | ok | ok | |
|
| groupBy | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| orderBy | ok | ok | |
|
| limit | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| count | ok | ok | |
|
| orderBy | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| getById | ok | ok | |
|
| count | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| search | ok | ok | |
|
| getById | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| get | ok | ok | |
|
| search | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| getFirst | ok | ok | |
|
| get | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| all | ok | ok | |
|
| getFirst | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
| setNull | ok | ok | |
|
| all | ok | ok | ok |
|
||||||
|
|------------------+---------------+---------+------------|
|
||||||
|
| setNull | ok | ok | ok |
|
||||||
|------------------+---------------+---------+------------|
|
|------------------+---------------+---------+------------|
|
||||||
|
|
||||||
* Contacto
|
* Contacto
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ class Model
|
|||||||
|
|
||||||
foreach ($atts as $key => $value) {
|
foreach ($atts as $key => $value) {
|
||||||
if (isset($value)) {
|
if (isset($value)) {
|
||||||
$into[] = "`$key`";
|
$into[] = "$key";
|
||||||
$values[] = ":$key";
|
$values[] = ":$key";
|
||||||
static::$queryVars[":$key"] = $value;
|
static::$queryVars[":$key"] = $value;
|
||||||
}
|
}
|
||||||
@@ -822,7 +822,10 @@ class Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') {
|
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') {
|
||||||
return static::leftJoin($table, $columnB, $operatorOrColumnB, $columnA);
|
$currentTable = empty(static::$querySelect['from']) ?
|
||||||
|
static::table() : static::$querySelect['from'];
|
||||||
|
static::$querySelect['from'] = $table;
|
||||||
|
return static::leftJoin($currentTable, $columnB, $operatorOrColumnB, $columnA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static::$querySelect['rightJoin'] .= ' RIGHT JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB";
|
static::$querySelect['rightJoin'] .= ' RIGHT JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB";
|
||||||
@@ -884,31 +887,22 @@ class Model
|
|||||||
*/
|
*/
|
||||||
public static function crossJoin(
|
public static function crossJoin(
|
||||||
string $table,
|
string $table,
|
||||||
string $columnA,
|
|
||||||
string $operatorOrColumnB,
|
|
||||||
?string $columnB = null
|
|
||||||
): static {
|
): static {
|
||||||
if (is_null($columnB)) {
|
static::$querySelect['crossJoin'] .= ' CROSS JOIN ' . $table;
|
||||||
$columnB = $operatorOrColumnB;
|
|
||||||
$operatorOrColumnB = '=';
|
|
||||||
}
|
|
||||||
|
|
||||||
static::$querySelect['crossJoin'] .= ' CROSS JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB";
|
|
||||||
|
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines GROUP BY in the SQL statement.
|
* Defines GROUP BY in the SQL statement.
|
||||||
*
|
*
|
||||||
* @param array $arr
|
* @param array $columns
|
||||||
* Columns to group by.
|
* Columns to group by.
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function groupBy(array $arr): static
|
public static function groupBy(string ...$columns): static
|
||||||
{
|
{
|
||||||
static::$querySelect['groupBy'] = join(', ', $arr);
|
static::$querySelect['groupBy'] = join(', ', $columns);
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -928,7 +922,7 @@ class Model
|
|||||||
if (is_null($quantity)) {
|
if (is_null($quantity)) {
|
||||||
static::$querySelect['limit'] = $offsetOrQuantity;
|
static::$querySelect['limit'] = $offsetOrQuantity;
|
||||||
} else {
|
} else {
|
||||||
static::$querySelect['limit'] = $offsetOrQuantity . ', ' . $quantity;
|
static::$querySelect['limit'] = $quantity . ' OFFSET ' . $offsetOrQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new static();
|
return new static();
|
||||||
@@ -1046,13 +1040,13 @@ class Model
|
|||||||
$search = static::bind($search);
|
$search = static::bind($search);
|
||||||
$where = [];
|
$where = [];
|
||||||
|
|
||||||
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') {
|
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
|
||||||
foreach ($in as $row) {
|
foreach ($in as $row) {
|
||||||
$where[] = "$row LIKE '%' || $search || '%'";
|
$where[] = "$row LIKE CONCAT('%', $search, '%')";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($in as $row) {
|
foreach ($in as $row) {
|
||||||
$where[] = "$row LIKE CONCAT('%', $search, '%')";
|
$where[] = "CAST($row AS TEXT) LIKE '%' || $search || '%'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user