Fixes for MySQL driver
This commit is contained in:
parent
9a9220ab24
commit
8cfc2aeb2a
3 changed files with 13 additions and 7 deletions
|
@ -15,6 +15,7 @@ class Database
|
||||||
self::$pdo = new PDO($dsn, $user, $pass);
|
self::$pdo = new PDO($dsn, $user, $pass);
|
||||||
self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||||
|
self::$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,14 @@ class Database
|
||||||
if (!self::connected())
|
if (!self::connected())
|
||||||
throw new Exception('Database is not connected');
|
throw new Exception('Database is not connected');
|
||||||
$statement = self::makeStatement($sqlQuery);
|
$statement = self::makeStatement($sqlQuery);
|
||||||
|
try
|
||||||
|
{
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
throw new Exception('Problem with ' . $sqlQuery->getSql() . ' (' . $e->getMessage() . ')');
|
||||||
|
}
|
||||||
self::$queries []= $sqlQuery;
|
self::$queries []= $sqlQuery;
|
||||||
return $statement;
|
return $statement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,8 @@ class PostEntity extends AbstractEntity
|
||||||
->select('post.*')
|
->select('post.*')
|
||||||
->from('post')
|
->from('post')
|
||||||
->innerJoin('crossref')
|
->innerJoin('crossref')
|
||||||
->on()->open()->raw('post.id = crossref.post2_id')->and('crossref.post_id = :id')->close()
|
->on()->open()->raw('post.id = crossref.post2_id')->and('crossref.post_id = ?')->close()->put($this->id)
|
||||||
->or()->open()->raw('post.id = crossref.post_id')->and('crossref.post2_id = :id')->close()
|
->or()->open()->raw('post.id = crossref.post_id')->and('crossref.post2_id = ?')->close()->put($this->id);
|
||||||
->put(['id' => $this->id]);
|
|
||||||
$rows = Database::fetchAll($query);
|
$rows = Database::fetchAll($query);
|
||||||
$posts = PostModel::convertRows($rows);
|
$posts = PostModel::convertRows($rows);
|
||||||
$this->setCache('relations', $posts);
|
$this->setCache('relations', $posts);
|
||||||
|
|
|
@ -104,9 +104,8 @@ class UserModel extends AbstractCrudModel
|
||||||
$query = new SqlQuery();
|
$query = new SqlQuery();
|
||||||
$query->select('*')
|
$query->select('*')
|
||||||
->from('user')
|
->from('user')
|
||||||
->where('LOWER(name) = LOWER(:user)')
|
->where('LOWER(name) = LOWER(?)')->put(trim($key))
|
||||||
->or('LOWER(email_confirmed) = LOWER(:user)')
|
->or('LOWER(email_confirmed) = LOWER(?)')->put(trim($key));
|
||||||
->put(['user' => trim($key)]);
|
|
||||||
|
|
||||||
$row = Database::fetchOne($query);
|
$row = Database::fetchOne($query);
|
||||||
if ($row)
|
if ($row)
|
||||||
|
|
Loading…
Reference in a new issue