Welcome Guest, Not a member yet? Register   Sign In
MySQL Queries using Doctrine & CodeIgniter
#1

[eluser]01010011[/eluser]
Hi,

How do I write plane SQL queries using Doctrine connection object and display the results? For example, how do I perform:
Code:
SELECT * FROM table_name WHERE column_name LIKE '%anything_similar_to_this%';

using Doctrine something like this (this example does not work)
Code:
$search_key = array('search_for_this');
        
     $conn = Doctrine_Manager::connection();
      
     $conn->execute('SELECT * FROM table_name WHERE column_name LIKE ?',  $search_key);
        
     echo $conn;
#2

[eluser]theprodigy[/eluser]
Quote:How do I write plane SQL queries using Doctrine connection object and display the results?

From Doctrine's Manual:
Quote:$stmt = $conn->prepare('SELECT * FROM test');
$stmt->execute();
$results = $stmt->fetchAll();
print_r($results);

So, I would assume (using your example):
Code:
$search_key = array('search_for_this');

$conn = Doctrine_Manager::connection();
$qry = $conn->prepare('SELECT * FROM table_name WHERE column_name LIKE ?',  $search_key)
$qry->execute();
$results = $qry->fetchAll();
print_r($results);

Something like that should work. But I don't use Doctrine, so I really couldn't say if that is the proper way to do it.




Theme © iAndrew 2016 - Forum software by © MyBB