Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. From briefly looking at what you are asking I think you should read up on design patterns, and in your case I think MVC ( Model, View, Controller) would best suit your needs. Using this approach allows you to logically separate the business logic (models) from the HTML ( view) by using a controller to request the data from the model and pass it to the view.

     

     

     

     

  2. Are you responsible for the world cities database? Or is it a remote resource ? If its yours then you need to ensure that the fields you are querying your autocomplete against are correctly indexed and that your search is specific

  3. When joining tables you will come across. Instances where a field in both tables have the same name. Because of this you cannot select just id, this would be an ambiguous field join. Instead you need to declare which table you wish to pull the Id from:

    SELECT notesnew.ID ,  content, owner, dp_time, profileimg FROM notesnew JOIN users on notesnew.owner = users.username
    

     

    A not to remember is that when you echo out the row it will just be ID and not notesnew.ID.

     

    If you wanted to pull the Id from both tables then you would be beat using an alias for each one:

    SELECT notesnew.ID AS 'notesId' , users.ID AS 'usersId'

  4. Ok, read up on the article posted by harries tweed, learning about table joins will help you a lot in the furture, a good rule of thumb that I personally use is that mysql queries should not go inside loops, joins should be used wherever possible. Looking at your table:

    SELECT content, owner, dp_time, profileimg FROM notesnew JOIN users on notesnew.owner = users.username
    

     

    Should do the trick

  5. Your trying to insert the user_id into the id field

    	 $sql_insert = "INSERT into `jobs` (`id`,`job_title`,`description`,`type`,`date`,`remuneration`,`terms`,`start_date`)

    Needs to be

    	 $sql_insert = "INSERT into `jobs` (`user_id`,`job_title`,`description`,`type`,`date`,`remuneration`,`terms`,`start_date`)

     

    You do not need to insert the id field as it auto increments

  6. Hi, sorry i misread your problem, was not firing on all cylinders (too early) lol.

     

    You might want to try using a nested select query. But be aware that if you are using a nested query the nested select can only return 1 row. Have a look at the query below and see if this puts you on the right tracks

     

    SELECT pr.note, pr.updated_on, pr.created_on, CONCAT( u.firstname,' ', u.lastname) AS UpdatedBy,
    (SELECT CONCAT( u.firstname,' ', u.lastname)  FROM prop_notes pr  JOIN users u ON pr.created_by = u.user_id   ) As createdBy
    FROM prop_notes pr 
    JOIN users u ON pr.created_by = u.user_id 
    WHERE pr.client_id = '".$_SESSION['client_id']."' AND pr.note_id = '".$page_note_id."' AND pr.deleteStatus = '0'
    

  7. You should never really put anything besides the index page and javascript, css etc into the public folder. you are in effect making the script accesible to the public domain. One of the main fundamentals of using a framework like Zend is that you application code is kept securely out of the public reach and all required code is passed to the view(index) through the controller.

     

    For the type of classes you are referring to (Authentication , access controll etc) you should think about moving the class into your default library folder. The library folder path is already included in the default zend framework structure. So below is an example of creating a plugins folder to house it.

     

    application/

    docs/

    library/

              Plugins/

                          Auth/

                                  MenuAcl.php

     

    so all you would need to add in your bootstrap would be:

            $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => ''));
            $resourceLoader->addResourceType('plugins', 'library/plugins/','Plugins_');
    

    and chage your class name to

    class Plugins_Auth_Acl extends  Zend_Acl
    {
    // code here
    }

     

  8. this line tells the autoloader where the starting directory is situated , in this case the

    APPLICATION_PATH

    . so for this it starts at the application folder:

    application/

                    models/

                                MenuAcl.php

     

    for this example the autoloader would keep parsing through the model folders sub directories looking for any classes beginning with the Model_ namespace. So if you were to move this model into another folder i.e:

    application/

                    models/

                                Auth/

                                        MenuAcl.php

     

    then you would have to amend the classes namespace to match :

    class Model_Auth_MenuAcl extends Zend_Acl
    {
    
    }

     

    have a look at the zend documentation :

    http://framework.zend.com/manual/en/zend.loader.autoloader.html

     

  9. Apologies, I missed a part of code out :(.

    Let me run you through an example of one of my autoloaders. Basically the

    Zend_Loader_Autoloader_Resource()

    allows you to add and manage namespaces with the with the zend autoloader. Please see the correct example below:

            $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => ''));
            $resourceLoader->addResourceType('form', 'forms/','Form_');
            $resourceLoader->addResourceType('plugins', 'library/plugins/','Plugins_');
            $resourceLoader->addResourceType('model','models/', 'Model_');
    

     

    Firstly you need to set the base path for the loader, in this case it is set to the application path, the addresourceType then takes in the arguments

     $typeOfresource,$filePath,$namespace

    .

    So for the model you are instructing the loader to look for classes within the models/ folder with the namespace prefix of Model_.

    I hope this helps.

     

  10. Hi, if you are only using mktime() to generate a timestamp for today then you might want to change:

       $date = mktime(0,0,0,date("m"),date("d"),date("Y"));

    With:

    $date  = time();

     

    One of the benefits of this is that the mktime you were using would give u a timestamp for midnight today. time() wil log the exact time the user registered.

     

    Another option is to ensure your register_date  datatype in the database is a DATETIME and just use

       $query = mysql_query("INSERT INTO members 
       (member_id, username, firstname, lastname, password, register_date, ip)
       VALUES   (0, '$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[password]',NOW(),'$ip')")

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.