Compare commits

..

7 Commits

2 changed files with 54 additions and 58 deletions

View File

@@ -33,83 +33,85 @@ En la siguiente tabla se encuentra la lista de estados de los gestores de bases
|------------------+---------------+---------+------------|
| 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

View File

@@ -453,7 +453,7 @@ class Model
foreach ($atts as $key => $value) {
if (isset($value)) {
$into[] = "`$key`";
$into[] = "$key";
$values[] = ":$key";
static::$queryVars[":$key"] = $value;
}
@@ -822,7 +822,10 @@ class Model
}
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";
@@ -884,31 +887,22 @@ class Model
*/
public static function crossJoin(
string $table,
string $columnA,
string $operatorOrColumnB,
?string $columnB = null
): static {
if (is_null($columnB)) {
$columnB = $operatorOrColumnB;
$operatorOrColumnB = '=';
}
static::$querySelect['crossJoin'] .= ' CROSS JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB";
static::$querySelect['crossJoin'] .= ' CROSS JOIN ' . $table;
return new static();
}
/**
* Defines GROUP BY in the SQL statement.
*
* @param array $arr
* @param array $columns
* Columns to group by.
*
* @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();
}
@@ -928,7 +922,7 @@ class Model
if (is_null($quantity)) {
static::$querySelect['limit'] = $offsetOrQuantity;
} else {
static::$querySelect['limit'] = $offsetOrQuantity . ', ' . $quantity;
static::$querySelect['limit'] = $quantity . ' OFFSET ' . $offsetOrQuantity;
}
return new static();
@@ -1046,13 +1040,13 @@ class Model
$search = static::bind($search);
$where = [];
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') {
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
foreach ($in as $row) {
$where[] = "$row LIKE '%' || $search || '%'";
$where[] = "$row LIKE CONCAT('%', $search, '%')";
}
} else {
foreach ($in as $row) {
$where[] = "$row LIKE CONCAT('%', $search, '%')";
$where[] = "CAST($row AS TEXT) LIKE '%' || $search || '%'";
}
}