I'm doing an upgrade for an older web app. As expected it has the support of older mysql functions (mysql) which requests to replace it with mysqli. Everything goes fine, except when searching for the function "mysql_lookup" and its relations to mysqli.. But even after browsing the web and this forum, I couldn't find any answers that would help or at least suggest how to solve this. Anyone with this experience and solution?
The mysql_lookup function is not part of the PHP mysql interface.
That function must be defined somewhere in your application, or in a library used by your application. You'll need to locate that function, see what it does, and probably reverse engineer it.
Related
bit of a theory question this one. I would like to write my own library for codeigniter. It's going to be from connecting to different british Accountancy packages via API's. If it were a single package I was writing it for then I could create the library easily, however, it will be multiple. I intend to load the library as follows:
$params = array('package' => 'quickbooks');
$this->load->library('accountancy', $params);
Through my research so far, each API does not offer the same functionality therefore my library will have to be able to disable/enable functions based on the selected package. Also, the api's are different so each function will have to work differently based on the selected package also.
Firstly, is a library the best course of action?
Does anyone have any tutorials they can point me to or anything else to help?
Not looking for someone else to write it for me, just looking to be pointed in the right direction.
Thanks
There are probably multiple solutions.
If what you need to accomplish can be conceived as an abstraction layer (which means that, regardless of which accounting package you're using, you use the same functions to get things done) then using the "Drivers" approach might work.
First, check out the CI documentation for Using CodeIgniter Drivers.
CI uses the driver pattern for the cache, database and session classes. Studying that source code may prove helpful. Cache.php might be the easiest to get your head around to start with.
Via Google I found one Codeigniter Drivers Tutorial and I'm pretty sure the Stack Overflow has some info too.
Here's another example of using CI drivers.
I confess that I didn't look at either tut very closely. So I'm not certain how helpful they will be.
I dont seem to see any popular php based tutorial sites ever talking about GDK. Is it even being used? If yes what is it that can be made? the way i see it is I have the ability to build a Linux application with php which is amazing but I honestly don't see what good it can do. Maybe if someone can shine some light on it for its great use?
thanks
I dont seem to see any popular php based tutorial sites
I am afraid it has some truth in it, some very helpful link are these:
Php Gtk Comunity page
http://php-gtk.eu/
Small tutorial
http://zetcode.com/gui/phpgtktutorial/
Sample scripts by widgets (this contains the most!)
http://www.kksou.com/php-gtk2/list-sample-codes-by-widgets/
A few other more specific link I distinguished are:
Php+Gtk+Cairo in Particular
http://zetcode.com/gui/phpgtktutorial/cairo/
I've done a class project on random walk (balls moving around on the screen) in cairo and it is a great library!
Few sample scripts
http://php-gtk.eu/en/gtk/gtkwindow
CairoForPHP Samples
http://fffree.phpws.org/?p=6
PHP-GTK installer for windows (this must be very helpful!)
http://php-gtk.eu/en/apps/php-gtk-installer-for-windows
Is it even being used?
There are a few projects displayed on the community page. I am working my self on a class project on descision support models.
Also I have made a comment here: https://stackoverflow.com/a/4522521/642173 that is somehow relative to your question.
I wish the future will be better for php-gtk, I think it is worth.
Is it inevitable that all php functions will be used sooner or later when developing applications using php? Should only the required functions be learned to complete a project or should all functions be briefly understood before working on programs using php?
The List:
PHP Function List
Also is there a benefit to learning deprecated functions from previous releases of php besides legacy applications?
I have worked quite a bit developing applications using the .NET framework (c#) and found it extremely helpful to understand mainly how the majority of classes work before undertaking a project. Before that it seemed like I was constantly looking back and forth between coding and documentation, and not that we should'nt be reading the documentation but that it takes the fun out of coding when you can't go a statement without looking at the documentation.
Now I have made basic applications using PHP, and the majority of it has been the way I just described. Can I get your thoughts on how functions in PHP should be approached?
It is impossible to learn all functions available in the PHP standard library. Impossible I say.
There are a few handful of functions you'll need every day, and you'll discover them rather quickly and learn them by heart simply by using them. Beyond that there are hundreds of specialized functions you'll need every once in a while, depending on the project. You'll probably need to look up their specifics whenever you need them. Beyond that there are thousands upon thousands of functions you'll rarely need, if ever. You'll need to be able to find those when the need arises, but not any sooner.
The best way is to keep the manual close at hand and search it whenever you think "there should be a function for that". You'll do this a lot in the beginning and less often later on.
Feel free to skim the manual for function groups, you may discover that there are functions for stuff you didn't even know you could do. That may be valuable knowledge some day. Do not try to memorize everything in detail though. It won't stick anyway and only bore you to tears.
It should be approached as with any other language - you try to code something, get stuck, look up the docs if you find something related to your problem and use that. Otherwise you extend your research. There is no need to learn everything and anything. Personally, I don't see the point of reading about all functions simply to have read of them. Why should I, if I don't need them? Even though this is not coding directly, YAGNI (you ain't gonna need it) applies here as well. Learn about the functions when the need arises, not simply because you can.
IMHO, you should understand what certain function does rather then how it is doing it.. Obviously there are exceptions of functions that are similar (i.e. str_replace vs preg_replace or print vs echo - mostly string functions) and knowing how they work might give you an insight of performance.
Learning ALL php functions is not really necessary as you will not need them in everyday coding. You'll learn as you go (e.g. you need to manipulate and array; then you go and read all PHP array function and see if any suits the need for your problem. rather then doing it another way around. learning all php functions and start coding)
I can only support th answers given...
It is more or less impossible because there are a lot of functions, and when you have learned all the function there are functions you do not know they exist.
You have no big benefit comparing to the time you need to learn them. All important functions you will use every day and so learn them by using them.
Every day there are new libraries, or new versions of existing and useful libraries, every day some other programmer writes a new function and post this function in one of the millions pages on the web.
When you need some special funciton, you will use the manual, or if it is some exotic function use google. And when there are no solution for you problem, you will code som own funcitons and libraries and use them instead of functions in the manual or other libraries...
So I think that are some of plenty reasons not to learn all php functions...
Of course not.
Only string manipulation ones.
Dunno where did you get that list. It's totally useless. Not list but structured reference is what you really need.
Just take a brief tour on manual sections to picture yourself list of PHP features, so, you'll know where to look on occasion.
Only string manipulation functions deserve closer look, just because PHP itself is mainly string manipulation language.
I'm currently working with an massive PHP codebase, witch is completely undocumented.
Here's the deal. All of the PHP code is included every page call. They build a simple include all kinda function that scan's the directory and includes all PHP files it can find. It works recursively for all the subfolders.
I would like to know what functions are used in what files and from which files those functions came.
I need to know this in order to switch to normale includes. Also it gives me more information about not used functions and files (since it a really old and big codebase, there is a lot of legacy in it).
It there a tool or something for PHP that can check this kind of stuff in a codebase?
NetBeans gives me pretty good visibility, for the spot inquiry. I'm interested to see if you get something with more value as a straight "audit" or inventory tool.
It's an old question so you seem to have found a solution. There's a php function: get_defined_functions(), get_defined_vars(), get_defined_constants(). You can use them in a page and you know the functions/vars/constants defined for use but not being used.
I'm in the process of trying to move our company from SalesForce to SugarCRM, but I've run in to a nasty bug (the moment I add a custom field to Accounts, all accounts stop showing up). We've paid for support from the SugarCRM people, but they only have take-forever-then-get-a-worthless-response-level tech support for the open-source version (and we avoid proprietary software like the plague). Oh, and did I mention our Salesforce contract expires at the end of the week?
So, long story short, I'm stuck debugging the SugarCRM app myself. I'm an decently experienced programmer, and I have baseline PHP competency, but I don't even know where to being trying to solve this issue. Can any Sugar developers out there recommend any kind of process for debugging Sugar? Are there any resources out there that would help me to understand what the different PHP files do, or how the Sugar system works overall?
Just as an example of the sort of thing I'm talking about: I figured out how to get sugar to print stack traces, and by following several I noticed a pattern with all the problem lines involving $this->_tpl_vars
I'd love to try and figure out why that method call isn't working, but I don't know:
A) what _tpl_vars is supposed to do
B) where _tpl_vars is defined
C) what $this is supposed to be
D) where in the framework $this gets set
etc.
So if anyone can help explain how/where I would start finding answers to these questions, I'd be incredibly grateful.
I worked with SugarCRM a couple years ago, and although I loved what I saw on the surface, I ended up rejecting it for our project because of what you are experiencing now. The internals of the product are woefully underdocumented. I had envisioned writing a bunch of slick modules for the product, but the resources just don't exist. You'll spend all your time digging through code, pouring over forum posts, and trying to find examples of what you're trying to accomplish. Doesn't sound like things have gotten much better.
Given that your PHP experience is less-than-guru level, and you're undoubtedly busy with a lot of other tasks and deadlines, I think you should maybe reconsider this transition if it's not too late, at least until you get a better comfort level with Sugar. If you're forced to move to Sugar because of an expiring contract with Salesforce, I think you might be in for some serious heartburn!
Use the Krumo library to help. It's super easy and way better than var_dump or print_r.
Simply download the source code and add it somewhere in your custom folder. I use the custom/include folder.
Then override a View or whatever you need to look at. Include the path to file class.krumo.php file, and krumo whatever object you want to take a look at:
Quick example -
<?php
require_once('include/MVC/View/views/view.detail.php');
require_once('custom/include/krumo/class.krumo.php');
class AccountsViewDetail extends ViewDetail {
function AccountsViewDetail() {
parent::ViewDetail();
}
// Override the parent function "preDisplay" to add our own template
function preDisplay(){
krumo($this->bean);
$metadataFile = $this->getMetaDataFile();
$this->dv = new DetailView2();
$this->dv->ss =& $this->ss;
$this->dv->setup($this->module, $this->bean, $metadataFile, 'custom/modules/Accounts/tpls/AccountsDetailView.tpl');
}
}
?>
You'll get a nice object on the page that you can drill into.
Although it's not a perfect answer to my question, this article:
http://developers.sugarcrm.com/wordpress/2008/09/26/where-is-the-code-for-x/
did help a bit. Also when I looked further through the official Sugar docs I found that the Developer Guide does contain some explanation of how Sugar works (although obviously it's not as focused on how Sugar works so much as it's focused on how to make Sugar do new things).
Hope that helps any other burgeoning Sugar devs out there.
These code are coming from Smarty lib, not coming from SugarCRM directly.
Maybe this chm doc will be a little helpful, http://code.google.com/p/sugardoc/downloads/list.
You can also try installing xdebug (PHP extension) and stepping through the code with a compatible IDE such as eclipse or Komodo.
The URL tells you which module directory is being accessed and which action/view. There's a "views" folder under most modules. If it's not there, it's either using the default MVC view in the include folder in conjunction with the metadata layout, or it's using the classic view architecture: index.php (listview), DetailView.php, and EditView.php and templates.
A lot has changed for the better in the last couple years, so I'm not sure the first answer (Nack) is still relevant. It's still pretty rough around the edges, but the new Sugar framework is a PHP hacker's best friend (really easy to override stuff in an upgrade-friendly manner). It's great for companies who happen to already have PHP hackers and only need a few enhancements. And finding affordable PHP contractors to help out isn't that hard (disclaimer: I am one). I think it's a great tool if you're into open source, just need basic CRM and have fewer than 100 users.
tpl is smarty template files. They are used when displaying data on screen. How i do my debuging proces is create a lot of var dumps to error lof or just print them on screen.
Also get xdebug on the server, this will help you a lot. Sugar is mvc platform so get knowing how that works, and will be much easier then.
take a look at some snippets i post at www.eontek.rs
If I encountered the same problem, when the detail page of the account wasn't displayed and gave 500 internal error. I checked that it was not generated by the TPL. At first I checked the permissions on that folder, in my case they were all set. So I took the backup of cache\modules\accounts\DetailView.tpl and manually added the field, after that everything worked. Every time in the developer mode there's a need to manually copy this file. It's a pain, but there's still no answer. I have asked this in forums, Bug, Twitter, no help. By the way, we are using Sugar Professional.
I'd suggest making sure that it really is a code bug and not just a miss config. Are you adding the field through Admin > Studio > Contacts > Fields or through the SOAP API ?
Are you using the latest version of Sugar?
I really agree that the project it horribly under-documented and lacking in tutorials and examples.
I myself am experiencing the pains of outdated / missing documentation.
Good luck!
$this is a reference to the current object.
class Test {
var $tmp;
function __construct() {
$this->tmp = 42;
}
}