Almost done, finish line!
Took 45 minutes
This commit is contained in:
@ -40,6 +40,15 @@ class FaqModel
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach( $result as $index => $value )
|
||||
{
|
||||
$result[$index]['question'] = substr( $result[$index]['question'], 0, 50 );
|
||||
$result[$index]['question'] = str_replace( "\n", ' ', $result[$index]['question'] );
|
||||
$result[$index]['answer'] = substr( $result[$index]['answer'], 0, 50 );
|
||||
$result[$index]['answer'] = str_replace( "\n", ' ', $result[$index]['answer'] );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -59,22 +68,22 @@ class FaqModel
|
||||
public function addQuestion(int $room_id, string $question)
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'INSERT INTO questions ( room_id, question, created_by ) VALUES ( :room_id, :question, :created_by )' );
|
||||
$stmnt->execute( array( 'room_id' => $room_id, 'question' => $question, 'created_by' => 'Anonymous' ) );
|
||||
$stmnt->execute( array( 'room_id' => $room_id, 'question' => htmlspecialchars( $question ), 'created_by' => 'Anonymous' ) );
|
||||
|
||||
}
|
||||
|
||||
public function addAnswer(int $question_id, string $answer)
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'UPDATE questions SET answer = :answer WHERE id = :id' );
|
||||
$stmnt->execute( array( 'answer' => $answer, 'id' => $question_id ) );
|
||||
$stmnt->execute( array( 'answer' => htmlspecialchars( $answer ), 'id' => $question_id ) );
|
||||
|
||||
}
|
||||
|
||||
public function checkUserIsRoomOwner( array $a_room )
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT owner_sid FROM rooms WHERE id = :id' );
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT id, owner_sid FROM rooms WHERE id = :id' );
|
||||
$stmnt->execute( array( 'id' => $a_room['id'] ) );
|
||||
$result = $stmnt->fetchAll( PDO::FETCH_ASSOC );
|
||||
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
|
||||
|
||||
if( $result === false || empty( $result ) )
|
||||
{
|
||||
@ -87,4 +96,18 @@ class FaqModel
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getQuestion( int $question_id)
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT * FROM questions WHERE id = :id' );
|
||||
$stmnt->execute( array( 'id' => $question_id ) );
|
||||
|
||||
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
|
||||
if( $result === false || empty( $result ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$result['question'] = str_replace( "\n", '<br>', $result['question'] );
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user