Welcome Guest, Not a member yet? Register   Sign In
  Using multiple MySQL databases
Posted by: El Forum - 08-09-2007, 02:40 PM - No Replies

[eluser]stevefink[/eluser]
Hi all,

First and foremost, I'm having a blast with the CI learning process! Unfortunately I've run into a hurdle where I'm going to have to ask the community for some insight. I'm working on a small application that requires speaking to two separate databases. I followed the advice listed here in order to achieve this:

http://ellislab.com/codeigniter/user-gui...cting.html

So in config/database.php I've created two elements in the $db array consistent of $db['db1'] and $db['db2']. My questions are the following:

1) Do we leave $active_group defined if we're using multiple databases?
2) Where would be the best place to define the actual DB object instances? The constructor or the index() method?

I wrote the following code in my controller's index():

function index()
{
$DB1 = $this->load->database('db1', TRUE);
$DB2 = $this->load->database('db2', TRUE);

// retrieve all records.
$data['query'] = $DB1->get('tbl_signups');

.. yadda yadda ..
This query is unfortunately is trying to query the database defined in $DB2 (probably cause of a user error. Tongue )

Thanks again for any insight folks!


  best practice of exposing data to a view
Posted by: El Forum - 08-09-2007, 02:18 PM - No Replies

[eluser]Bacteria Man[/eluser]
I'm using a controller->library->model structure. The controller is extremely thin and is responsible for only displaying the view. The library contains all the business logic and the model interacts with the database.

With the above in mind, I'm trying to determine the best practice of exposing data to a view.

The most obvious way is to pass the data in the second parameter. For example:

Code:
$data['title'] = 'My Blog';
$this->load->view('blogview', $data);

What about data produced by the library? I like to return true/false from my functions. If false, the function failed for whatever reason. If true, the data is defined as an object and available to the view.

I suspect that a combination of both techniques is acceptable.

I'd appreciate any comments and/or a confirmation.

Thanks!


  silly question
Posted by: El Forum - 08-09-2007, 01:20 PM - No Replies

[eluser]gafro[/eluser]
hey guys,

quick simple question.

where do i place the css directory?

heres my link

<link rel="stylesheet" href="styles/global.css" type="text/css" media="screen, projection" />


  Validation question
Posted by: El Forum - 08-09-2007, 12:38 PM - No Replies

[eluser]chobo[/eluser]
I was doing some validation with the validation class and I was just wondering where do the variables that you are testing get stored? Currently, I validate the variables and then retrieve them from the post array like this:

Code:
$this->input->post('somefield', true);

Does retrieving the variables using CI's input->post class get the validated variables, or unfiltered ones directly from the form?

Thanks!


  How can I made this ?? - begineer
Posted by: El Forum - 08-09-2007, 11:04 AM - No Replies

[eluser]fejtis[/eluser]
Hi

i have maybe stupid question. I am thinking on the situation, where I have a web with CodeIgniter and in all pages I want to process something code (for example SQL query). So i must repeat that code in all controllers? Thx


  HTML Table display horizontally/changing orientation
Posted by: El Forum - 08-09-2007, 08:32 AM - No Replies

[eluser]Carlton[/eluser]
Is it possible to alter the orientation of a table....at the moment I have a table with 60+ columns and 2 rows so ideally would like to display it as 60+ rows and 2 columns. Similar to how you would layout a form I guess.

Is this possible using the table library at all?


  MySQL Connection / PHP complaints
Posted by: El Forum - 08-09-2007, 04:44 AM - No Replies

[eluser]danfloun[/eluser]
Hi,
I've just installed the latest xampp and have installed Code Igniter which so far is looking good. I've run through the tutorials to get to grips with the basics but I've hit a minor problem

Although I seem to have no connection failures I get an error at the top of my index.php when trying to access the MySQL database.

The error:

Code:
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant database - assumed 'database'

Filename: config/autoload.php

Line Number: 41

My test server:

Apache: 2.2.4
PHP: 5.2.3
MySQL: 5.0.45


My autoload.php

Code:
$autoload['libraries'] = array(database);

My database.php

Code:
$active_group = "default";

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "mypassword";
$db['default']['database'] = "blog";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

Thanks for any help


  Authentication Script
Posted by: El Forum - 08-09-2007, 04:38 AM - No Replies

[eluser]Kemik[/eluser]
Hello all,

Just wondering whether you think I should code my own authentication script (login, logout, register, forgotten password, remember me).

I can code the register script and the admin backend so I don't really need a full featured plugin but I've never really dove in to cookies and managing how the user would login with CI. I'll also need to be able to call to see if the user is logged in, an admin, etc.

By using a full featured plugin such as FreakAuth I can simply use it straight away after a few tweaks and it'll be easy enough to upgrade later. Plus, the script is very detailed in how it manages the user.

Are there any other auth plugins that I should look at and are still in active development?

Thanks.


  using loaded language file inside controller, possible?
Posted by: El Forum - 08-09-2007, 04:30 AM - No Replies

[eluser]moonbeetle[/eluser]
In my constructor I load the language file according to the user's preference like this:

Code:
// Load language file
$this->lang->load('products', $this->db_session->userdata('lang'));

in the language file I'm loading I have an entry:
Code:
$lang['next_link'] = 'Volgende';
("Volgende" means "Next" in Dutch)

This works fine and when I load a view file I can use data from my loaded language file. So the controller is perfectly capable of loading the language file and passing the data to the view file. However, what I can't do or can't figure out is how to use the loaded language data directly inside the controller. Why would I want to do this? For setting the config values for pagination where language dependancy is needed for instance.

This works (obviously):
Code:
$config['next_link'] = 'Next'

But this doesn't:
Code:
$config['next_link'] = $this->lang->line('next_link');
nor will this:
Code:
$config['next_link'] = $lang['next_link'];

Does anyone have a solution for this?


  Japanese (multi-byte) characters & email library
Posted by: El Forum - 08-09-2007, 03:15 AM - No Replies

[eluser]Aaron L.[/eluser]
Hello, In my controller (encoded in UTF-8) I am attempting to send an email which contains Japanese (multibyte) characters. The body of the email comes out fine, but the subject line are just garbled characters. Any ideas/tips/hints/thoughts as to what might be going on here?


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Heads up for users using ...
by davis.lasis
1 hour ago
curl + response body
by okatse
2 hours ago
Tool bar not showing
by grimpirate
3 hours ago
The Hidden Cost of “Innov...
by fcoder
10 hours ago
tool bar not showing
by InsiteFX
Yesterday, 09:09 PM
Validation does not appea...
by grimpirate
Yesterday, 01:55 PM
Block IP addresses of bad...
by grimpirate
Yesterday, 01:47 PM
Override Router
by grimpirate
Yesterday, 01:30 PM
CodeIgniter.com - Report ...
by Vikas Mehta
06-30-2025, 10:30 AM
best way to store tokens ...
by ahallrod
06-30-2025, 10:03 AM

Forum Statistics
» Members: 154,366
» Latest member: Michal788
» Forum threads: 78,436
» Forum posts: 379,709

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB