first commit
This commit is contained in:
45
autoload/factory/class.Messages.php
Normal file
45
autoload/factory/class.Messages.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace factory;
|
||||
|
||||
class Messages {
|
||||
|
||||
public function addMessage( $text, $link )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pro_messages ( text, link ) VALUES ( :text, :link )' );
|
||||
$query -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function markMessageAsReaded( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pro_messages SET readed = 1 WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getMessages()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pro_messages WHERE readed = 0 ORDER BY date DESC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$messages[] = $row;
|
||||
$query -> closeCursor();
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user