We can't access the `$this->table` property before initialization, so let's use `isset()` to check if the property has a value.
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/52
This PR fixes a bug where if no conditions are passed to `MySQL->from("table")->delete()`, the generated query will look like this:
```sql
DELETE FROM `table` WHERE
```
This is obviously invalid SQL syntax. This PR only adds the `WHERE` keyword and rules if conditions have been supplied to either `where()` or with `delete([])`
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/51
This PR just sets the `OFFSET` value to `0` if no offset is provided for all calls to `limit()`. This fixes a bug where no `OFFSET` was set if the `$limit` parameter was given an integer.. which was the only allowed type except null anyways.
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/50
Of course I missed to change one reference of `for()` to `from()`.
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/48
Co-authored-by: vlw <victor@vlw.se>
Co-committed-by: vlw <victor@vlw.se>
I made a rushed merge with #41 and it doesn't work properly.. it throws an exception when passing an `Order` enum to the method, because we're only accepting strings. #42
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/43
Importable with:
```php
use vlw\MySQL\Order
```
To be used with the `MySQL->order()` method, for example:
```php
$db->for("table")->order(["column" => Order::ASC])->select("*");
```
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/41
This PR adds a compliment for the `MySQL->filter_values` property but for filter columns which can be accessed from a protected scope with `MySQL->filter_columns`
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/40
This PR removes the `where()` method which I don't think is particularly useful and also very untested since I don't use it personally at all. It's also probably better to do in-model checking for table columns **before** sending it off to this library when required anyways.
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/37
Co-authored-by: vlw <victor@vlw.se>
Co-committed-by: vlw <victor@vlw.se>
The name I gave this years ago "libmysqldriver" never sat right with me.. okay it might be considered a library for mysql but it's *definitely* not a driver.
Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/36
Co-authored-by: vlw <victor@vlw.se>
Co-committed-by: vlw <victor@vlw.se>